1

note that i'm using asp.net with vb.net

jquery:

$("#create")
.button().click(function () {
$("#dialog-form").dialog("open");
});

$("#LinkButton3").click(function () {
        $("#dialog-form").dialog("open");
        return false;
    });

asp:

<asp:TemplateField HeaderText="Edit">
    <ItemTemplate> 
        <asp:LinkButton ID="LinkButton3" runat="server">LinkButton</asp:LinkButton>
    <a href="#" class="table-actions-button ic-table-edit" id="create"></a>
     </ItemTemplate> 
</asp:TemplateField> 

the dialog opens for the a tag but does not open for the linkbutton can anyone tell me why my code is not working?

1

5 Answers 5

1

The id of linkbutton on client side would be different so use the ClientID to bind the event. Also put binding code indocument.ready. Assign a class to linkbutton and use class selector to bind event.

Html

<asp:TemplateField HeaderText="Edit">
    <ItemTemplate> 
        <asp:LinkButton ID="LinkButton3" runat="server" class="someclass">LinkButton</asp:LinkButton>    <a href="#" class="table-actions-button ic-table-edit" id="create"></a>
     </ItemTemplate> 
</asp:TemplateField> 

Javascript

$('.someclass').click(function () {
    $("#dialog-form").dialog("open");
    return false;
});

If you need to use id for select then use attribute selector with starts with wild card.

$('[id=^LinkButton3]').click(function () {
    $("#dialog-form").dialog("open");
    return false;
});
Sign up to request clarification or add additional context in comments.

Comments

0

Use ClientID to get server control in jquery like this.

  var create= "#<%=create.ClientID%>";
    $(create).on('click', function() { 
      $("#dialog-form").dialog("open");
    });

Don't forget to include js file and js code inside document.ready .

Comments

0

Try this

Add UseSubmitBehavior="false" to your asp link button

your html

<asp:TemplateField HeaderText="Edit">
    <ItemTemplate> 
        <asp:LinkButton ID="LinkButton3" runat="server" UseSubmitBehavior="false">LinkButton</asp:LinkButton>
    <a href="#" class="table-actions-button ic-table-edit" id="create"></a>
     </ItemTemplate> 
</asp:TemplateField> 

Comments

0

LinkButton is server side asp.net controls which causes postback. Another point is you are not using the correct id of the control it's changed. Try with $('#<%=LinkButton3.ClientID%>').

Comments

0

Replace you link button with this

<asp:LinkButton ClientIDMode="Static" ID="LinkButton3" runat="server">LinkButton</asp:LinkButton>

see this:

ClientIDMode="Static"

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.