Hi to all. I have the small class below. and a webform
empty to test this class...
If i call to the method generate fields the application
show me the fields, if i click the button the controls
dissapear. But if in the constructor of the class below i
add the controls, this controls dont dissapear if i click
the button in the webform...
Why?
public class
mywebcontrol:Sy stem.Web.UI.Web Controls.WebCon trol
{
public TextBox MyTextBox
{
get{return mytextbox;}
set{mytextbox=v alue;}
}
public Button MyButton
{
get{return mybutton;}
set{mybutton=va lue;}
}
public mywebcontrol()
{this.MyButton. Click+=new EventHandler
(MyButton_Click );
}
public void MyButton_Click( object sender, EventArgs
e) {
HttpContext.Cur rent.Response.W rite (this.MyTextBox .Text);
}
public void Generate_Fields ()
{ TextBox new_textbox=new TextBox();
this.MyTextBox[i]=new_textbox;
this.Controls.A dd(this.MyTextB ox[i]);
this.Controls.A dd(this.MyButto n);
}
}
}
Thanks In advanced
The main program...
empty to test this class...
If i call to the method generate fields the application
show me the fields, if i click the button the controls
dissapear. But if in the constructor of the class below i
add the controls, this controls dont dissapear if i click
the button in the webform...
Why?
public class
mywebcontrol:Sy stem.Web.UI.Web Controls.WebCon trol
{
public TextBox MyTextBox
{
get{return mytextbox;}
set{mytextbox=v alue;}
}
public Button MyButton
{
get{return mybutton;}
set{mybutton=va lue;}
}
public mywebcontrol()
{this.MyButton. Click+=new EventHandler
(MyButton_Click );
}
public void MyButton_Click( object sender, EventArgs
e) {
HttpContext.Cur rent.Response.W rite (this.MyTextBox .Text);
}
public void Generate_Fields ()
{ TextBox new_textbox=new TextBox();
this.MyTextBox[i]=new_textbox;
this.Controls.A dd(this.MyTextB ox[i]);
this.Controls.A dd(this.MyButto n);
}
}
}
Thanks In advanced
The main program...