J
John Kilgo
I'm dynamically adding literals and .net controls to a Placeholder control. Everything works to a point(my literals are added and my controls are added). But I need to add an event handler, specificall for a checkbox. My code is something like this:
litText = new Literal();
litText.ID = "anID";
phContent.Controls.Add(litText);
litText.Text = "Some Text";
CheckBox myCheckBox = new CheckBox();
myCheckBox.ID = "aCheckBox";
myCheckBox.TextAlign = TextAlign.Right;
myCheckBox.Text = "SomeText";
phContent.Controls.Add(myCheckBox);
Then I'm trying to do something like the following:
myCheckBox.CheckedChanged += new System.EventHandler(myCheckBox_CheckedChanged);
It burps with the message "c:\inetpub\wwwroot\MainPetitionDynamic\WebForm1.aspx.cs(34): The name 'myCheckBox_CheckedChanged' does not exist in the class or namespace 'MainPetitionDynamic.WebForm1'
I've a couple of other syntaxes but nothing seems to work. How can I add the event handler dynamically.
Thanks,
John
___
Newsgroups brought to you courtesy of www.dotnetjohn.com
litText = new Literal();
litText.ID = "anID";
phContent.Controls.Add(litText);
litText.Text = "Some Text";
CheckBox myCheckBox = new CheckBox();
myCheckBox.ID = "aCheckBox";
myCheckBox.TextAlign = TextAlign.Right;
myCheckBox.Text = "SomeText";
phContent.Controls.Add(myCheckBox);
Then I'm trying to do something like the following:
myCheckBox.CheckedChanged += new System.EventHandler(myCheckBox_CheckedChanged);
It burps with the message "c:\inetpub\wwwroot\MainPetitionDynamic\WebForm1.aspx.cs(34): The name 'myCheckBox_CheckedChanged' does not exist in the class or namespace 'MainPetitionDynamic.WebForm1'
I've a couple of other syntaxes but nothing seems to work. How can I add the event handler dynamically.
Thanks,
John
___
Newsgroups brought to you courtesy of www.dotnetjohn.com