Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
When I developed my application with masterpage I enter some validation in content page.

It will work fine, but after some time it will stop working.

This is my javascipt function it is simple but it stopped working.
XML
function reset()
    {
    document.getElementById("<%=txt_fh_name.ClientID%>").value="";
    document.getElementById("<%=txt_mobile.ClientID%>").value="";
    document.getElementById("<%=txt_add.ClientID%>").value="";
    document.getElementById("<%=txt_email.ClientID%>").value="";
    }



Can anybody tell me how to solve this problem or why it is doing like this?
Thanks.
Posted
Updated 10-May-12 4:52am
v3
Comments
Dylan Morley 9-May-12 9:02am    
So what's actually happening when it's 'not working'? Have you used your debugger of choice (Firebug, Chrome, IE Developer tools) to analyse why it's not working. Any script errors being reported?

Try adding break points, looking for errors....you can figure this out yourself.
Sandeep Mewara 9-May-12 9:26am    
You need to elaborate more on 'not working' part.
Zoltán Zörgő 9-May-12 16:12pm    
Are you sure, that those elements have unique ID's all the time? Look at the generated html code. But a debugger is indispensable...

When We are Using Master Pages and Put our content in ContentPlace Holder then the ID of the control will be changed you can see in the source code your textbox ID will start with "ct100" so sometime there will be a issue that while using

document.getElementById("<%=txt_fh_name.ClientID%>").value="";
will not able to get ID

The easiest way is just copy the rendered ID from source code and put in the
getElementById method it will work properly.
 
Share this answer
 
Check your html source code and check the generated id's of the controls..are they same...

or try document.getElementByName instead of using document.getElementByID

let me know what happens..?

make it answer if it works...

Thanks
Ashish
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900