How To: Show JQuery Dialog from ASP.NET code behind!!!

How To: Show JQuery Dialog from ASP.NET code behind!!!

I'm writing this article to How to show a JQuery Dialog from ASP.NET code behind.

Here is the code snippet to show JQuery Dialog 

 private void ShowAlert(string message)
        {
            ///Initialize the stringbuilder object to append JS script
            StringBuilder sb = new StringBuilder();
            sb.Append("$(function() { ");
            sb.Append("$('#alertdialog').empty();");
            sb.Append("$('#alertdialog').append('" + message + "');");
            sb.Append(" $('#alertdialog').dialog({");
            sb.Append("    width: 350,");
            sb.Append("buttons: {");
            sb.Append("'Close': function () {");
            sb.Append("$('#alertdialog').dialog('close');");
            sb.Append("}");
            sb.Append("   }");
            sb.Append(" });");
            sb.Append("});");
            ///Register the script on page startup
            ClientScript.RegisterStartupScript(typeof(Page), "myscript"sb.ToString(), true);
            
        }
 ShowAlert("your message here");
Hope this tip will be useful for developers creating ASP.NET web applications with JQuery.
Leave a Comment
  • Please add 7 and 8 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
Page 1 of 1 (1 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
Page 1 of 1 (1 items)