Sunday, 3 November 2013

Resolve problem of SimpleModal not being displayed when adding ScriptManager on the page

I came across the plug-in called "SimpleModal" that was developed by plasm in Mootools. You can read more and run the demo on http://simplemodal.plasm.it



This modal works great. However, SimpleModal doesn't work if there is ScriptManager on the page. I'm disappointed a bit because most of ASP.NET pages need ScriptManager to handle the Postback. After searching around for solutions but getting no luck. There seems to be no answers on Internet. I decided to investigate what the cause might be. Accidentally, I found a workaround. It's quite simple. I tried to do something with ScriptManager by going through all of its attributes. And here is the idea:

Workaround: Assign a value to ScriptPath. It could be any value, as long as it's not empty. See the highlighted section below:
<asp:ScriptManager ID="ScriptManager1" runat="server" ScriptPath="MyCustomScriptPath">
</asp:ScriptManager>

Now please compare the source view before and after adding ScriptPath. Use the online tool (http://www.diffnow.com/) to see the difference.

In below screen (click to room in), the left half represents the source that causes SimpleModal problem and the right half represents the changes (ScriptPath):


Now. It works pretty good. At least, I can use SimpleModal for many ASP.NET pages in my projects. For complicated pages, I'm not sure if there are any other conflicts :-) Then, I'll go about resolving it once I encounter these.

You can download the modified demo code at: SimpleModal

That's it. I'm so relieved!
Please share with me on my blogs if you have any finding with this plug-in.


1 comment:





  1. $(function () {
    function SimpleModal(msg) {
    var SM = new SimpleModal({ "btn_ok": "Alert button" });
    SM.show({
    "title": "Mais detalhes",
    "contents": msg
    });
    }
    });








    ReplyDelete