all groups > c# > march 2005 >
You're in the

c#

group:

emergency


RE: emergency Peng Jie
3/11/2005 9:39:03 PM
c#:
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);


[quoted text, click to view]
emergency Shawn Zheng
3/11/2005 11:44:54 PM
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

RE: emergency CBretana
3/12/2005 2:03:01 AM
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)

[quoted text, click to view]
RE: emergency Shawn Zheng
3/12/2005 8:53:35 PM


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?



*** Sent via Developersdex http://www.developersdex.com ***
RE: emergency Shawn Zheng
3/12/2005 8:53:41 PM


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

*** Sent via Developersdex http://www.developersdex.com ***
AddThis Social Bookmark Button