0

I am currently selecting an

<asp:Label id="lblLoginusername"..../>

So I am trying to get a reference to it (to later on change its value) by writing the following in my google chrome browser:

$("#<%= lblLoginUsername.ClientID%>")

I DO have jquery (1.7.2.min) in my page, but unfortunately I am getting:

[Exception: Error: Syntax error, unrecognized expression: >]

Can anyone guide me as to where I have a silly mistake?

1 Answer 1

1

first i dont know the exception if it was server side exception then the problem will be from your asp tag , recheck how you written the syntax

in jquery when selecting an element you select by its html attribute not by its asp.net properties and the ID tag in asp.net is not equal to the id attribute in html , so what you can do is figuring out the id attribute is from the generated html , or add a class name the select by that class

what your doing in chrome is writing $("#<%= lblLoginUsername.ClientID%>") that means find the element on page that its id attribute equal to "#<%= lblLoginUsername.ClientID%>" wich is not html at all its asp.net command, the browser wont undrstand it `

Sign up to request clarification or add additional context in comments.

2 Comments

oh ok i get it now, it's something that I cannot write in the browser, I have to write it into code so that then it is rendered correctly! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.