8

I want to use jGrowl plugin for jQuery (http://stanlemon.net/projects/jgrowl.html#samples) to display some messages on a page. To do this, I call the ScriptManager.RegisterClientScriptBlock method like this:

ScriptManager.RegisterClientScriptBlock(this, typeof(Page), Guid.NewGuid().ToString(),
   "$.jGrowl('" + message + "');", true);

The code works perfect in Firefox/Chrome/Safari. However in Internet Explorer I don't see the notification and I don't get any Javascript error.

I work under Windows 7 and I have Internet Explorer 8 Beta (version 8.0.7000.0) and I have the same "bug" under Compatibility Mode.

How can I solve this problem?

Stefan Filip
  • 1,791
  • 3
  • 15
  • 25

3 Answers3

12

This problem occurs because IE8 expects all the DOM elements to be loaded before modifications to the DOM can be made. I was able to duplicate the problem you described with jGrowl.

To fix it, I just modified your script so that the call to jGrowl happens once the document is ready. Here's the updated code:

ScriptManager.RegisterClientScriptBlock(this, typeof(Page), 
     Guid.NewGuid().ToString(),
     "$(function(){$.jGrowl('" + message + "');});", true);
Jose Basilio
  • 50,714
  • 13
  • 121
  • 117
  • Thanks for your answer. I tried you fix, but it's still not working. Could be because of the fact I have an update panel on the page? – Stefan Filip May 10 '09 at 10:20
  • I did test this code with an update panel and it worked fine. Did you actually copy/paste the code above? Are you getting any javascript errors in the browser? – Jose Basilio May 10 '09 at 17:26
  • If after doing this, you still have a problem, you may need to updgrade to the final version of IE8 instead of the Beta. – Jose Basilio May 10 '09 at 17:28
2

add <form runat="server" id="form1"> to page. It will work...

Ugur CAN
  • 21
  • 1
0

If not wrong, I think you have to add this in the client side page.

<script language="javascript" type="text/javascript" id="forModalPopUp">
    var prm =  Sys.WebForms.PageRequestManager.getInstance();
    prm.add_initializeRequest(InitializeRequest);
    prm.add_endRequest(EndRequest);
    function InitializeRequest(sender, args) {
    }
    function EndRequest(sender, args) {
    }
</script>

For more details, take a look at this.

4castle
  • 32,613
  • 11
  • 69
  • 106
456qwe123asd
  • 191
  • 4
  • 17