AWSHelpdesk
asked on
getElementById not working on master page
I have a user control which has a document.getElementById call and it works on all of the pages I put the user control on except when I use the user control on a content page that uses a master page then I get the error document.getElementById is not a function?
I don't have any spelling errors or anything like that because the control works fine when it is not on a master page page
I don't have any spelling errors or anything like that because the control works fine when it is not on a master page page
This is the javascript function within the user control where the error is occuring on Master Page content pages only
function ClearNoTab() {
//alert('called');
var noTabsDiv = document.getElementById('noTab');
if (noTabsDiv != null) {
noTabsDiv.style.display = "none";
}
}
This is the actual object;
<div id="noTab" style="display: none;">
Test<asp:Literal ID="litNominatedArticleNoTab" runat="server"></asp:Literal> </div>
Check to see if you have multiple document elements that have "noTab" as the id attribute.
wait a minute... I just re-read the statement again. You get an error "document.getElementById" is not a function? Wow, that's strange.
Can you provide the whole page?
Is the code where the document.getElementById() call exists with a <script> clause?
What does the <script> tag look like?
Does it look like?
Can you provide the whole page?
Is the code where the document.getElementById() call exists with a <script> clause?
What does the <script> tag look like?
Does it look like?
<script type='text/javascript'>
or
<script language='JavaScript'>
Hi! By using MasterPages, the control names are renderd differently. The control id is prefixed by ctl01_ctl02...
Something like
document.getElementById('c tl00_Conte ntPlaceHol der1_Contr ol name').value
or you want to use this
document.getElementById("< %=Controln ame.Client ID %>").value
Something like
document.getElementById('c
or you want to use this
document.getElementById("<
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.