|
-
Oct 9th, 2007, 09:01 AM
#1
Thread Starter
Member
How to destry a control?
i have following code:
private void BuildPostSurveyQuestionTable(int ID)
{
// I create a table here each time
// and clear all the rows second time and create a new one again then i create following button control
HtmlTableCell cellCommand;
HtmlTableRow rowCommand;
ValidationSummary valsum = new ValidationSummary();
valsum.ValidationGroup = "submit";
valsum.ShowMessageBox = false;
valsum.ShowSummary = false;
cellCommand = new HtmlTableCell();
cellCommand.ColSpan = 3;
cellCommand.Align = "right";
Label lblSubmitStatusPost = new Label();
lblSubmitStatusPost.ID = "lblSubmitStatusPost";
Button btnSubmitPost = new Button();
btnSubmitPost.Text = "Save";
btnSubmitPost.CommandArgument = ID.ToString();
btnSubmitPost.Click += new EventHandler(btnSubmitPost_Click);
btnSubmitPost.ValidationGroup = "submit";
cellCommand.Controls.Add(valsum);
cellCommand.Controls.Add(lblSubmitStatusPost);
cellCommand.Controls.Add(btnSubmitPost);
rowCommand = new HtmlTableRow();
rowCommand.Cells.Add(cellCommand);
tblEvaluation.Rows.Add(rowCommand);
}
I have to call this code multiple times. But its works fine the first time only, when i call it second time it doesn't jump on btnSubmitPost_Click(), after clicking the button it should jump to btnSubmitPost_Click() every time but why it only works for first survey only and not for the second one? Do I need to destry this control everytime after creating it? how do i do this?
Thanks
-
Oct 10th, 2007, 03:41 PM
#2
Re: How to destry a control?
You seem to be creating the control(s) but not maintaining viewstate for those controls... which is why you may be losing the event information each time.
There's a good article from 4guys about this: http://aspnet.4guysfromrolla.com/articles/092904-1.aspx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|