How to control where a dynamic table is displayed in asp.net?

Melissa m

New member
Hi, I'm working on a multiplication table generator that creates a table based on user input. When the person clicks my submit button the page is posted to itself and displays the table at the top of the page above everything else.

I'm coding it in C# and it uses a series of loops and Response.Write commands. Is there a way to display it at the bottom of the page instead of the top and include it in my container div tags?

Please help me!

Here's my code for the default page...

<%@ Page Language="C#" Inherits="project3.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Melissa's Multiplication Table Generator</title>
</head>
<body>
<div style="width: 600px; margin: auto">
<h1>Melissa's Multiplication Table Generator</h1>
<form id="form1" runat="server">
<p>Enter parameters into the textboxes below to generate a multiplication table, just like the kind I grew up with.</p>
<asp:Label runat="server" Text="Label">Enter Highest Horizontal Boundary:</asp:Label>
<asp:TextBox runat="server" id="text1" name="text1" width="50"></asp:TextBox><br/>
<asp:Label runat="server" Text="Label">Enter Highest Vertical Boundary:</asp:Label>
<asp:TextBox runat="server" id="text2" name="text2" width="50"></asp:TextBox><br/>
<asp:Button runat="server" Text="Generate It!" id="submit" name="submit" OnClick="submit_Click"></asp:Button>
<asp:Button runat="server" Text="Reset" name="reset" id="reset" OnClick="reset_Click" />

</form>
</div>
</body>
</html>

Here's the code for the default.aspx.cs file...

using System;
using System.Web;
using System.Web.UI;

namespace project3
{


public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{

}
protected void submit_Click(object sender, System.EventArgs e)
{
int maxHorz = 0;
int maxVert = 0;
int i = 0;
int x = 0;

maxHorz = Convert.ToInt32(text1.Text);
maxVert = Convert.ToInt32(text2.Text);



Response.Write("<table border='1' cellpadding='10'><tr><td>*</td>");

for (i = 0; i < maxHorz + 1; i++)
{
Response.Write("<td>" + i + "</td>");
}
Response.Write("</tr>");
for (x = 0; x < maxVert + 1; x++)

{
Response.Write("<tr>");
Response.Write("<td>" + x + "</td>");
for (i = 0; i < maxHorz + 1; i++)
{
Response.Write("<td>" + i * x + "</td>");
}
Response.Write("</tr>");
}
Response.Write("</table>");

}

protected void reset_Click (object sender, System.EventArgs e)
{
text1.Text = "";
text2.Text = "";
}
}
}
 
Back
Top