[Mono-list] self modifying tables

dietmar dietmar@ximian.com
14 Feb 2003 17:53:48 +0100


--=-C/OiCrkcd2QdaX0GG3BZ
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

fixed some bugs in the code 
On Fri, 2003-02-14 at 17:36, dietmar wrote:
> I want to implement self modifying tables with asp.net, but the attached
> examples does not work. Maybe someone can point me to the right
> solution?
> 
> - Dietmar

--=-C/OiCrkcd2QdaX0GG3BZ
Content-Disposition: attachment; filename=test2.aspx
Content-Type: text/html; name=test2.aspx; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

<%@ Page Language="C#" %>
<html>
<head>
<script runat="server">

bool add_entry = false;

void Clicked (Object sender, EventArgs e)	
{
	Console.WriteLine ("ADD database entry");
	add_entry = true;
}

// example 1: Clicked is called after Page_Load, so add_entry is always false
void Page_Load (object o, EventArgs e)
{
	TableRow row;
	TableCell cell;

	Console.WriteLine ("PAGELOAD");

	row = new TableRow ();
		
	cell = new TableCell ();
	LinkButton lb = new LinkButton ();
	lb.Text = "TEST2";
	lb.Click += new EventHandler (Clicked);
	cell.Controls.Add (lb);
	row.Cells.Add (cell);

	if (add_entry) {
		Console.WriteLine ("PAGELOAD ADD");
		row = new TableRow ();
		cell = new TableCell ();
		lb = new LinkButton ();
		lb.Text = "ADDED ENTRY";
		lb.Click += new EventHandler (Clicked);
		cell.Controls.Add (lb);
		row.Cells.Add (cell);
	}

	t1.Rows.Add (row);
}

</script>


<title>LinkButton as submit and command</title>
</head>
<body>
<form runat="server">
<asp:Table id="t1" runat="server"/>
</form>
</body>
</html>


--=-C/OiCrkcd2QdaX0GG3BZ
Content-Disposition: attachment; filename=test3.aspx
Content-Type: text/html; name=test3.aspx; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

<%@ Page Language="C#" %>
<html>
<head>
<script runat="server">

bool add_entry = false;

void Clicked (Object sender, EventArgs e)	
{
	Console.WriteLine ("ADD database entry");
	add_entry = true;
}

// example 2: creating linkbuttons in PreRender does not work
void Page_PreRender (object o, EventArgs e)
{
	TableRow row;
	TableCell cell;

	Console.WriteLine ("PAGELOAD");

	row = new TableRow ();
		
	cell = new TableCell ();
	LinkButton lb = new LinkButton ();
	lb.Text = "TEST3";
	lb.Click += new EventHandler (Clicked);
	cell.Controls.Add (lb);
	row.Cells.Add (cell);

	if (add_entry) {
		Console.WriteLine ("PAGELOAD ADD");
		row = new TableRow ();
		cell = new TableCell ();
		lb = new LinkButton ();
		lb.Text = "ADDED ENTRY";
		lb.Click += new EventHandler (Clicked);
		cell.Controls.Add (lb);
		row.Cells.Add (cell);
	}

	t2.Rows.Add (row);
}

</script>


<title>LinkButton as submit and command</title>
</head>
<body>
<form runat="server">
<asp:Table id="t2" runat="server"/>
</form>
</body>
</html>


--=-C/OiCrkcd2QdaX0GG3BZ--