Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET2.0 Javascript Masterpage , +
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 21:19pm
Comments
AshishChaudha at 10-Jan-13 3:39am
   
could you please share your code of javascript
Rate this: bad
good
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.
  Permalink  
Rate this: bad
good
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.......
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

you cant specify the id value like this
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 BillWoodruff 170
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,777
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 10 Jan 2013
Copyright © CodeProject, 1999-2014
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