Click here to Skip to main content
13,000,324 members (74,670 online)
Rate this:
Please Sign up or sign in to vote.
See more: , +
hello all,

i am having a problem.When i was working in an application without master page and content page, javascript was working finely.But later i needed to use mastr paga in my project.After using master page, javascripts is giving error on call of the function.
error is like below.

"Microsoft JScript runtime error: 'document.getElementById(...)' is null or not an object"

how should i put the javascript in content page.

please help as soon as possible.

thanking you
function enable()
document.getElementById('<%= txtID.ClientID%>').disabled=true;
Posted 9-Jan-13 20:19pm
AshishChaudha 10-Jan-13 3:39am
could you please share your code of javascript
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

When masterpage is added, the the id's of elements on the page are changed. You should view your page in browser and watch its code. There you will have the correct ID generated for the element("txtID"). In your javascript function use the ID generated in the HTML source code of your page.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

When you are working with master page right click on the page in IE browser from there you can get the id of the control in non-conventional format (unlike regular id) use that id in java script. Follow this process and try sure you will get it. Any doubts ask me.

Happy Coding.......
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

you cant specify the id value like this

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 10 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100