0

I'm creating a new web project and i trying to get jQuery working with masterpages

I want to have a link that if it is pressed will do an expansion of a div.

Problem: jQuery isn't fired and the page do a postback

enter image description here

3 Answers 3

2

ASP.NET control IDs are not the same as JavaScript element IDs. ASP.NET modifies IDs before sending them to the client. In your .aspx file's JavaScript, instead of simply hp1, specify something like:

<%= hp1.ClientID %>
Sign up to request clarification or add additional context in comments.

Comments

2

You can set

ClientIdMode="Static"

if you are using Visual Studio 2010

If not, you can always use a CSS selector like

$('.YourControl').click(function(){ alert('hi'); });

And in your aspx

<asp:HyperLink ID="yourId" cssClass="YourControl" />

Comments

1

Do not use asp:HyperLink, instead use just a

Comments

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.