emergency

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I think you can try to remove

protected RadioButton radio;

If you already defined radio as a control in form, how can you add it again
with

this.controls.add(radio);
 
Help!!!
I want to dynamicaly create controls in ASP.NET Web form in the following
code.

protected RadioButton radio;

private void Page_Load()
{
radio = new RadioButton();
radio.Text = "new lable";
this.controls.add(radio);
}

Why I can not do it in this way. the error says the control is not added to
form.
How do I resove it. It seems this.controls not belong to the web form. Is it
strange?

Shawn
 
I believe you can't add radio button controls to the Page.Controls... You
must add to a Form.controls collection

HtmlForm HTMLF = new HtmlForm();
foreach(Control ctl in this.Controls)
{
if (ctl.GetType() == HTMLF.GetType())
{
//now that we have found the form control, we can add the
radiobutton
radio = new RadioButton();
radio.Text = "new lable";
ctl.Controls.Add(radio);
(untested)
 
Do you know how can I make a small portion of a page scrolling up/down
automatically? In Natscape, there is Layer concept that looks can be
used to accomplish this problem. Is there a simiar in Windows?
 
Thank you, CBretana
You are right. the object of 'this' is not a Form's object.
I resoved this problem by adding a asp table and add radio buttons in
table's cells.

Shawn
 
Back
Top