Mohammad Olfatmiri
Mohammad Olfatmiri

Reputation: 1675

ASP.NET link button doesn't work with jquery

I have a jQuery plugin that is use for tabbing menu like this code:

div id="tabsWithStyle" class="style-tabs">
        <ul>
             <li>
                <asp:LinkButton ID="Tozih"  OnClick="Tozih_Click" href="#facebook"  runat="server"><div class="icon picasa-icon">توضیح</div></asp:LinkButton>
            </li>
                <li>
                <asp:LinkButton ID="books" OnClick="books_Click"     runat="server"><div class="icon picasa-icon">کتاب</div></asp:LinkButton>
            </li>
              <li>
                <asp:LinkButton ID="jozve" OnClick="jozve_Click"  href="#facebook"  runat="server"><div class="icon picasa-icon">جزوه</div></asp:LinkButton>
            </li>
</ul>

and the jQuery is:

    <script type="text/javascript">
        $(function () {
            $('#tabsWithStyle').tabs();
        });
    </script>  

also #facebook is a div

   <div id="facebook">
countent
</div>

Edit : it's server-side event (C# code).

My problem is that onClick events don't work when I click on it

What's my problem ?

Edit 2 :

enter image description here

Edit 3:

protected void books_Click(object sender, EventArgs e)
{
    Response.Redirect("NewsFeed.aspx");
}

Upvotes: 0

Views: 1105

Answers (3)

AB Vyas
AB Vyas

Reputation: 2389

Try this.

In your Linkbutton add one attribute causesvalidation

<asp:LinkButton ID="jozve" OnClick="jozve_Click" causesvalidation="false"  href="#facebook"  runat="server"><div class="icon picasa-icon">جزوه</div></asp:LinkButton>

Upvotes: 0

cinek
cinek

Reputation: 1952

Since you are using serverside control you need to use client id:

$('#<%= Tozih.ClientID %>').on('click', function(){
  //your code, 'this' is a clicked element
});

Upvotes: 0

Dextere
Dextere

Reputation: 301

Try this

$("#Tozih").on("click", function(event){
alert("clicked on Tozih"); 
});

Upvotes: 1

Related Questions