I have a textbox in webuser control. And i am accessing it in content page and add its text
change event handler as follow…
protected void Page_PreInit(object sender, EventArgs e)
{
Find = (TextBox)(Menu1.FindControl("txtTarget"));
Find.TextChanged += new EventHandler(Find_TextChanged);
}
void Find_TextChanged(object sender, EventArgs e)
{
}
Now i have a linkbutton in the same web user control. when i click this linkbutton the text change event of that text is automatically fires.
How i can stop this event to occur when click the link button?
Every time the textbox posts back, it checks its value; if different than the previous server value, it fires the TextChanged event. I don’t believe there are any ways around that. However, what I think you can do is put an if condition that if the link button was clicked, ignore the handle:
It may be ClientID, but I’m pretty sure it posts the UniqueID, and therefore, you can check that the link caused the postback not process TextChanged.