c# - Javascript Issue on MasterPage -
I have found a piece of JavaScript that cleans the data in the text box. This code works well on a standalone page, but does not work on the master page.
My JavaScript is on the default page:
& lt; Script type = "text / javascript" & gt; Function doClear (searchbox) {if (searchbox.value == searchBox.defaultValue} {searchBox.value = ""}}
and I am the same as I To attach the OnClick property:
Secure Zero Page_load (Object Sender, EventArgs e) {Textbox1.Attributes. Add ("OnClick", "Door (Search Box);" );}
The error 'search box' is undefined!
Any help is greatly appreciated.
Matt
You have to do something,
safe Zero Page_load (Object Sender, EventArgs E) {Textbox1.Attributes.Add ("onclick", "doClear ('" + TextBox1.ClientId +' ''); ");}
When you use Master Pages, ASP.net can convert your client ID into your HTML elements to ensure that they are unique. See the section called 'Name Mangling'.
< / Div>
Comments
Post a Comment