(Assuming VS.NET 2003) In the designer select the TextBox control and in the
properties window, click on the yellow lightning bold. Type in OnTextChanged
next to the Action "TextChange d".
In the code behind, you should see that the method InitializeCompo nent has
changed to add a line that attaches an event handler to the TextChanged event
of the TextBox:
private void InitializeCompo nent()
{
this.TextBox1.T extChanged += new System.EventHan dler(this.OnTex tChanged);
this.Load += new System.EventHan dler(this.Page_ Load);
}
And
Now in the method called by the TextChanged event handler, you can bind your
dropdown.
private void OnTextChanged(o bject sender, System.EventArg s e)
{
myDropDownList. DataBind();
}
"Vi" wrote:
sender.GetType( ).FullName returns "ASP.WebOrderFo rm_aspx", which is the
name of the page.
Is there a way to determine that it was the TextBox that generated the
postback?
Thanks.
"Haacked" wrote:
Try printing out the value of sender.GetType( ).FullName.
"Vi" wrote:
Hello,
I want to be able to reload a DropDownList when a TextBox changes its value.
So I set the AutopostBack property of the TextBox to true and in the code
behind I do something like:
if(IsPostBack)
{
if( ((TextBox)sende r).ID == "myTextBox" )
myDropDownList. DataBind();
}
I receive an error "Specified cast is not valid" in the if(
((TextBox)sende r).ID == "myTextBox" ) line.
What am I doing wrong?
Thank you,