Jon's Blog

.NET Development & More

ASP.NET AJAX UpdatePanel + jQuery UI Dialog

The jQuery UI Dialog does not seem to play nicely with the ASP.NET AJAX UpdatePanel.  After doing a partial page postback using an UpdatePanel the jQuery UI Dialog div would no longer function.  Thanks to Stack Overflow and some blog posts I discovered that you need to add some code to hook into the ASP.NET AJAX JavaScript pageLoaded event and this will reinitialize the jQuery UI Dialog div every time.  We also need to append the div to the form element so that any ASP.NET buttons on the div will post back to our page.  In the following JavaScript snippet my jQuery modal dialog div has an ID of "myDiv". Also, in this example we are setting up the dialog to be modal and autoOpen equal to false.

<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function (evt, args) {

    var myDiv = $("#myDiv").dialog({ autoOpen: false, modal: true, open: function (type, data) {
         $(this).parent().appendTo("form");
        }
    });
});
</script>
Comments are closed
Jon's Blog | Archive

Jon's Blog

.NET Development & More

Archive

RSSBlog (37)

Date Title
2013-06-30 ASP.NET MVC and jQuery UI Autocomplete
2013-03-01 Reporting Services: Unspecified Error
2013-02-15 Using SQL Session State with Multiple Environments
2011-05-03 ASP.NET AJAX UpdatePanel + jQuery UI Dialog
2011-01-24 LINQ: Complicated Advanced Search with Dynamic Where Clause
2011-01-24 ASP.NET: Improving Your Error Logging & Handling
2010-12-15 ASP.NET AJAX: Return to Top of Page After Partial Postback
2010-09-01 How to Use FreeTextTable
2010-08-19 ASP.NET: Fun with Paths and Directories
2010-07-16 Hiding ASP.NET Ajax Modal Popup Dialog Using JavaScript
2010-06-15 ASP.NET AJAX: UpdateProgress Displaying Behind DropShadowExtender Control
2010-05-20 Visual Studio: System.Web.AspNetHostingPermission Failed
2010-04-27 Removing Control From Tab Order
2010-03-26 LinqDataSource: Efficient Custom Paging with LINQ
2010-03-16 Implementing Server Side Output Caching in an HTTP Handler
2010-03-16 Problem Debugging ASHX HTTP Handler
2010-02-10 Source Safe: The character encodings on these files are different. Only files with the same character encoding can be merged or compared.
2010-02-02 LINQ: Mapping to an Enumerated Type in the LINQ Designer
2010-01-22 SQL: Converting DateTime to MM/DD/YYYY Format
2009-11-20 GridView EmptyDataTemplate: Get Rid of That Annoying Border!
2009-11-20 ASP.NET AJAX Control Toolkit: Bug with Modal Popup Extender
2009-09-22 ASP.NET: Beware of Blank ImageUrl on ImageButton
2009-09-22 ASP.NET AJAX: Checking for Partial Postback - IsInAsyncPostBack
2009-09-16 LINQ Advanced Search
2009-08-11 Using ASP.NET and GDI+ to Resize Uploaded Image
2009-08-10 File Upload: File Extension Validation
2009-07-30 IE8: Image max-width bug
2009-07-27 DropDownList: Customized DataTextField
2009-07-14 SQL Server Trigger for Row Archive
2009-07-14 ASP.NET AJAX Web Service Call
2009-06-29 ASP.NET: Add New Error Message to Validation Summary Control
2009-06-29 SQL Server: UNIQUE Constraint Syntax
2009-06-10 That Pesky Enter Key: JavaScript to the Rescue
2009-06-10 AJAX Control Toolkit: Strange CSS Bug with HTML Editor control and IE 8
2009-05-28 Visual Studio: Build failed due to validation errors in dbml file
2009-05-13 LINQ, Visual Studio, and Stored Procedure Mapping
2009-05-02 My Selfish Blog

RSSWindows 7 (1)

Date Title
2009-12-13 Windows 7: Turtle Beach Santa Cruz Sound Card

Total

38 posts