Since I have to use this in lot of places (not only in button clicks) I have come up with the generic function like the one in below which emits javascript.
public void SetFocusControl(string ControlName)
{
string script = "<script language=\"javascript\"> var control = document.getElementById(\"" +
ControlName + "\");" + " if( control != null ){control.focus(); if(control.type == 'text') control.select();}" +
"</script>";
Page.RegisterStartupScript("Focus", script);
}
So whenever I want to set the focus to particular control I would call this fuction with that control name.
when I dont want I dont call this, still the Page emits the javascript which was emitted at the last time.
So I want to remove that script. is there any way to remove the registered script using the key or in some other way?
Thanks