Solved

referencing controls - getElementById

Posted on 2013-02-01
6
139 Views
Last Modified: 2013-02-01
Can anyone please explain the difference between these three statements, and if they are all valid?


document.getElementById("<%= lblProcessingMsg.ClientID %>");

document.getElementById("lblProcessingMsg.ClientID");

document.getElementById(lblProcessingMsg);
0
Comment
Question by:HLRosenberger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 11

Accepted Solution

by:
mcnute earned 500 total points
ID: 38843916
This is not exclusively javascript:

In the first statement you have a serverside scripting tag, which could be ruby, asp, jsp, etc.
It is valid if the method called within the chevrons returns a string which is represented within the following dom.

The second statement will be valid if there is a dom element in your page which has the id of lblProcessingMsg.ClientID.

The third statement is valid if in your javascript block before the statement a variable has been created with the name lblProcessingMsg and the variable is of type string and the value is represented by a dom element with that value in its ID attribute.

Hope that helped.
mcnute
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 38843955
What is chevrons ??
0
 
LVL 11

Expert Comment

by:mcnute
ID: 38843966
angular brackets <>. In this case they are wrapping some server side code probably embeded ruby which is used in ruby on rails.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:HLRosenberger
ID: 38843981
OK.  This is ASP, actually.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 38844244
Thanks
0
 
LVL 82

Expert Comment

by:leakim971
ID: 38844278
http://www.4guysfromrolla.com/articles/031710-1.aspx

the first one is the good syntax to reference the label in a javascript code for :
<asp:Label ID="lblProcessingMsg" runat="server" Text="bla bla" />

Open in new window

the second one is a useless string, or for this one :
<span id="lblProcessingMsg.ClientID">bla bla</span>

Open in new window

the third one :
<asp:Label ID="lblProcessingMsg" runat="server" Text="bla bla" />

Open in new window

With:
function someFunction() {
        var lblProcessingMsg = "<%= lblProcessingMsg.ClientID %>";
        document.getElementById(lblProcessingMsg);
}

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question