I call a thick box when I click a link:
<a href="createContact.aspx?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=400&width=550&modal=true" title="Add a new Contact" class="thickbox">Add a new Contact</a>
And, when the server button is pressed, I call this javascript function to show the jGrowl notification:
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), Guid.NewGuid().ToString(), "$(function(){$.jGrowl('No Contact found: " + searchContactText.Text + "');});", true);
Both work as expected, except when jGrowl is shown first than thick boxing. This will cause the thick box to not work, and the page will be shown as a normal network (as if the thick box disappeared).
Does anyone know what is going on?
UPDATE: this is a test page without a main page:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="RoutingPortal.Presentation.WebForm2" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="../Scripts/jquery-1.6.2.js" type="text/javascript"></script> <script src="../Scripts/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script> <script src="../Scripts/thickbox.js" type="text/javascript"></script> <script src="../Scripts/jquery.jgrowl.js" type="text/javascript"></script> <link href="../Scripts/css/jquery.jgrowl.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="~/CSS/thickbox.css" type="text/css" media="screen" /> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <div> <a href="createContact.aspx?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=400&width=550&modal=true" title="Add a new Contact" class="thickbox">Add a new Contact</a> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> </div> </ContentTemplate> </asp:UpdatePanel> </form> </body> </html>
This is codebehind:
namespace RoutingPortal.Presentation { public partial class WebForm2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { ScriptManager.RegisterClientScriptBlock(this.Page, typeof(Page), Guid.NewGuid().ToString(), "$(function(){$.jGrowl('My Message');});", true); } } }
I just tested it without UpdatePanel and it worked perfectly. So this is definitely a problem with UpdatePanel or a way to interact with jGrowl called from code.
I would really appreciate your help.
UPDATE: I even created a demo project where this problem can be easily identified. I would not want to send it to anyone who wants to help me with this. Thanks in advance guys!
UPDATE: I also tried the solution given by @Rick, changing the way jGrowl script was executed with codebehind:
ScriptManager.RegisterStartupScript(this.Page, typeof(Page), Guid.NewGuid().ToString(), "$.jGrowl('My Message');", true);
However, the problem persists, since the result is exactly the same. Any other ideas? I would really appreciate your help.
UPDATE: I also tried this in IE8 and Chrome, having run into the same problem. Thus, this has nothing to do with the browser. Just in case.