Archive for February, 2015
Trouble Shooting: Unable to perform postback from Jquery Dialog
Posted by A2H in Trouble Shooting on February 27, 2015
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