Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @{
- Page.Title = "Table generator";
- Layout = "MainLayout.cshtml";
- int rows=3,cols=5;
- if (IsPost) {
- rows = int.Parse(Request["txtRows"]);
- cols = int.Parse(Request["txtColumns"]);
- }
- }
- <form method="post">
- <div>
- Rows: <input type="number" name="txtRows" value="@rows" /> Columns: <input type="number" name="txtColumns" value="@cols" /><br />
- <button type="submit" class="btn">Create</button>
- </div>
- @if (IsPost) {
- <table class="table table-striped">
- <thead>
- <tr>
- @for (int c = 1; c <= cols; c++) {
- <th>Header @c</th>
- }
- </tr>
- </thead>
- <tbody>
- @for (int r = 1; r <= rows; r++) {
- <tr>
- @for (int c = 1; c <= cols; c++) {
- <td>
- Row @r, column @c
- </td>
- }
- </tr>
- }
- </tbody>
- </table>
- }
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement