Maintaining State

  • Thread starter Thread starter Jim Heavey
  • Start date Start date
J

Jim Heavey

I have a placeholder control and in code I am adding a asp.net Table
control and a button control.

When I press the button (right now the event handler procedure only writes
a line to the Console) I make a round trip to the server, but the event
procedure is never executed. Also my table disappears even after I have
set the property to EnableViewState = true.

Why does my table not maitain state?
Why does my event procedure not execute?

Here is my code to set the event handler....

Button bntAddHighlightComment = new Button();
bntAddHighlightComment.Text = "Add Comment";
bntAddHighlightComment.Click += new System.EventHandler
(AddHighlightComments_Click);
plcDataEntry.Controls.Add(bntAddHighlightComment);

Here is my event handler code...

private void AddHighlightComments_Click(object sender, System.EventArgs e)
{
Console.WriteLine("Made it to button click event");
}


Thanks in advance for your assistance!!!!!!!!
 
Hi, Jim Heavey,

On every postback to the server the page object gets instantiated and what
you work with is the instance. If your controls are "static" (added to the
html part of the page) the parser does the job to instantiate the control
objects and add the references to the page object. If you decide to go for
the harder way (dynamically add the controls, that is) you must redo
everything on every postback - create the table, add it to the placeholder,
add the button, attach the event etc.

Hope this helps
Martin
 
It's the miracle of stateless programming...you'll grow to love it:

----- Jim Heavey wrote: ----

Boy, that bumbs me out...
 
Back
Top