timeshifter

Untitled

Mar 1st, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.78 KB | None | 0 0
  1. @{
  2.     Page.Title = "Table generator";
  3.     Layout = "MainLayout.cshtml";
  4.    
  5.     int rows=3,cols=5;
  6.     if (IsPost) {
  7.         rows = int.Parse(Request["txtRows"]);
  8.         cols = int.Parse(Request["txtColumns"]);
  9.     }
  10.    
  11.    
  12. }
  13.  
  14.  
  15.  
  16. <form method="post">
  17. <div>
  18.     Rows: <input type="number" name="txtRows" value="@rows" />   Columns: <input type="number" name="txtColumns" value="@cols" /><br />
  19.     <button type="submit" class="btn">Create</button>
  20. </div>
  21. @if (IsPost) {
  22. <table class="table table-striped">
  23.     <thead>
  24.         <tr>
  25.             @for (int c = 1; c <= cols; c++) {
  26.             <th>Header @c</th>
  27.             }
  28.         </tr>
  29.     </thead>
  30.     <tbody>
  31.         @for (int r = 1; r <= rows; r++) {
  32.         <tr>
  33.             @for (int c = 1; c <= cols; c++) {
  34.             <td>
  35.                 Row @r, column @c
  36.             </td>
  37.             }
  38.         </tr>
  39.         }
  40.     </tbody>
  41. </table>
  42. }
  43. </form>
Add Comment
Please, Sign In to add comment