getElementById

HLRosenberger
HLRosenberger used Ask the Experts™
on
Are both of these statements correct?  If yes, why?   If not, why?

getElementById("<%= txtBrand.ClientID %>")

getElementById("txtBrand.ClientID")

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Statement1 is correct if there is a <asp:TextBox ID=txtBrand"... element on the page

<%=txtBrand.ClientID%> will be replaced by the unique id of the textbox while parsing.


Statement2 will search for a DOM element in the html page that is named txtBrand.ClientID  
I assume you are using ASP.net and the compiler will replace the <asp:Textbox tags by html replacements which do have other names.

So Statement2 is not correct.

Author

Commented:
OK  Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial