Millerbean
Millerbean

Reputation: 295

asp.net masterpage jQuery function

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

Upvotes: 0

Views: 104

Answers (3)

Zo Has
Zo Has

Reputation: 13038

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" />

Upvotes: 2

Andrei Schneider
Andrei Schneider

Reputation: 3563

Do not use asp:HyperLink, instead use just a

Upvotes: 1

John Pick
John Pick

Reputation: 5650

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 %>

Upvotes: 2

Related Questions