Trouble Shooting: Unable to perform postback from Jquery Dialog

Problem Description:

From Jquery Dialog when you click on the button and if it has a corresponding click event on server side code, the code won’t get executed.

Solution:

You need to add the below code to perform postback when user click on button in Jquery dialog.

parent().appendTo(jQuery("form:first"));

Complete Code

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css">
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css">
    <script>
        $(function () {
            $("#dialog").dialog({
                autoOpen: false
            });

            $("#Button1").click(function (evt) {
                var dlgwnd = $("#dialog").dialog("open");
                //Add the below code and Postback will occur fine with out any problem
                dlgwnd.parent().appendTo(jQuery("form:first"));
            });
        });
    </script>
</head>
<body>
    <form id="form2" runat="server">
        <div id="dialog" title="Dialog">
            Sample Text Content
            <asp:Button ID="Button2" runat="server" Text="OK" OnClick="Button2_Click" />
        </div>

        <asp:Button ID="Button1" runat="server" Text="Open Dialog" OnClientClick="return false" />
    </form>
</body>
</html>

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: