G
Guest
Hi,
I am having this problem:
I have developed a composite component which has 2 components: a textbox and a button.
I need to add an eventhandler to a button click. I have added the eventhandler, in the CreatechildControls override, but it doesn't work.
this is the code:
namespace Space1
{
public class LookUp: System.Web.UI.WebControls.WebControl , INamingContainer
{
protected System.Web.UI.WebControls.TextBox txtRisultato = new TextBox();
protected System.Web.UI.WebControls.Button BtnLookUp = new Button();
public LookUp()
{
EnsureChildControls() ;
}
private void BtnLookUp_Click(Object sender, EventArgs e)
{
txtRisultato.Text = "Hi!!!";
}
protected override void CreateChildControls ()
{
Controls.Add(BtnLookUp);
Controls.Add(txtRisultato);
BtnLookUp.Text = "...";
Controls.Add (new LiteralControl ("<TABLE>"));
Controls.Add(new LiteralControl("<TR>"));
Controls.Add(new LiteralControl("<TD>"));
Controls.Add(txtRisultato);
Controls.Add(new LiteralControl("</TD>"));
Controls.Add(new LiteralControl("<TD>"));
Controls.Add(BtnLookUp);
Controls.Add(new LiteralControl("</TD>"));
Controls.Add(new LiteralControl("</TR>"));
Controls.Add (new LiteralControl("</TABLE>"));
BtnLookUp.Click+=new EventHandler(BtnLookUp_Click);
}
}
}
How can I fire the button click event?
Thank you
Alessandro Rossi
I am having this problem:
I have developed a composite component which has 2 components: a textbox and a button.
I need to add an eventhandler to a button click. I have added the eventhandler, in the CreatechildControls override, but it doesn't work.
this is the code:
namespace Space1
{
public class LookUp: System.Web.UI.WebControls.WebControl , INamingContainer
{
protected System.Web.UI.WebControls.TextBox txtRisultato = new TextBox();
protected System.Web.UI.WebControls.Button BtnLookUp = new Button();
public LookUp()
{
EnsureChildControls() ;
}
private void BtnLookUp_Click(Object sender, EventArgs e)
{
txtRisultato.Text = "Hi!!!";
}
protected override void CreateChildControls ()
{
Controls.Add(BtnLookUp);
Controls.Add(txtRisultato);
BtnLookUp.Text = "...";
Controls.Add (new LiteralControl ("<TABLE>"));
Controls.Add(new LiteralControl("<TR>"));
Controls.Add(new LiteralControl("<TD>"));
Controls.Add(txtRisultato);
Controls.Add(new LiteralControl("</TD>"));
Controls.Add(new LiteralControl("<TD>"));
Controls.Add(BtnLookUp);
Controls.Add(new LiteralControl("</TD>"));
Controls.Add(new LiteralControl("</TR>"));
Controls.Add (new LiteralControl("</TABLE>"));
BtnLookUp.Click+=new EventHandler(BtnLookUp_Click);
}
}
}
How can I fire the button click event?
Thank you
Alessandro Rossi