jquery dialog calls a server side method with button parameters

Posted by Chiefy on Stack Overflow See other posts from Stack Overflow or by Chiefy
Published on 2010-05-27T21:09:47Z Indexed on 2010/05/27 21:11 UTC
Read the original article Hit count: 135

Hello all,
I have a gridview control with delete asp:ImageButton for each row of the grid. What I would like is for a jquery dialog to pop up when a user clicks the delete button to ask if they are sure they want to delete it.
So far I have the dialog coming up just fine, Ive got buttons on that dialog and I can make the buttons call server side methods but its getting the dialog to know the ID of the row that the user has selected and then passing that to the server side code.

The button in the page row is currently just an 'a' tag with the id 'dialog_link'. The jquery on the page looks like this:

$("button").button();
    $("#DeleteButton").click(function () {
        $.ajax({
            type: "POST",
            url: "ManageUsers.aspx/DeleteUser",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {

                // Replace the div's content with the page method's return.
                $("#DeleteButton").text(msg.d);
            }
        });
    });

    // Dialog           
    $('#dialog').dialog({
        autoOpen: false,
        width: 400,
        modal: true,
        bgiframe: true

    });

    // Dialog Link
    $('#dialog_link').click(function () {
        $('#dialog').dialog('open');
        return false;
    });


The dialog itself is just a set of 'div' tags. Ive thought of lots of different ways of doing this (parameter passing, session variable etc...) but cant figure out how to get any of them working. Any ideas are most welcome

As always, thanks in advance to those who contribute.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about jQuery