页面使用无刷新控件,我想在后台调用js代码,打开模态窗口,不知道怎么设置,网上搜罗了一下,但在实际应用中依然不能实现,望高手指点~~

解决方案 »

  1.   

    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", 
    "window.showModalDialog(url,window,'dialogWidth=800px;dialogHeight=500px;center=1;')", true);
      

  2.   

    function aa()
    {
       window.showModalDialog(url,window,'dialogWidth=800px;dialogHeight=500px;center=1;');
    }ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "aa();",true);
      

  3.   


    你是不是直接把代码贴上去用的。如果是的话,那你得把 
    window.showModalDialog(url,window,'dialogWidth=800px;dialogHeight=500px;center=1;')", true);这里面参数 url 写上啦。否则显示不出来的。
      

  4.   

    OK  出来了 ,这样直接写js代码可以,为什么把js代码放到前台他就不执行了呢
      

  5.   

    贴下我的代码吧:后台代码
    string ss = "431234";
            string js = @"var xxx = function (){ 
                          aa('"+ss+@"')
                        }
                        if(document.all)
                        {
                            window.attachEvent('onload', xxx);
                        }
                        else
                        {
                            window.addEventListener('load', xxx , false);
                        }";
             ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "",js, true);前台代码:
    function SModalDialog(width, height, url, sendmsg) {
                var WinSettings = "center:yes;resizable:no;dialogHeight:" + height + "px;dialogWidth:" + width + "px;scroll:auto;";
                var Myarg = window.showModalDialog(url, sendmsg, WinSettings);
                if (Myarg == "refresh")
                    window.location.href = window.location.href;
            }        function aa(obj) {
                SModalDialog(550, 270, "test2.aspx?key=" + obj + "&timestamp=" + new Date().getTime(), null);
            }
    这样写的话,就不会弹出模态窗口了,不知道什么原因