asp.net服务器端执行javascript代码

点击提交按钮,确认是否已经登陆,如果没有登陆弹出登陆窗口,如果已经登陆,直接提交评论.

if (!object.Equals(null, Session["userInfo"]))
        {
            this.btnSubmit.Visible = true;
            this.btnOpen.Visible = false;
        }
        else
        {
            this.btnSubmit.Visible = false;
            this.btnOpen.Visible = true;
            this.btnOpen.Attributes.Add("onclick", "OpenWin()");
        }

        //打开模态窗体
        string strscript = "\n";
        if (!Page.IsClientScriptBlockRegistered("clientscript"))
        {
            strscript = "<script>\n";
            strscript += "function OpenWin(){\n";
            strscript += "var strlist=new Array(2);var width=(window.screen.width - 403) / 2;var height=(window.screen.height - 258) / 2; var str=window.showModalDialog('http://register.staging.ha.edu.cn/LoginPanel.aspx','','dialogLeft:' + width + 'px;dialogTop:' + height + 'px;dialogWidth=403px;dialogHeight=258px;help:no;location:no;toolbar:no;menubar:no;center:yes;scrollbars:no;z-look :no;alwaysRaised :no;resizable:no;scroll:no;location:no;status:no');\n";
            strscript += "if(str!=null){ }\n";
            strscript += "}\n";
            strscript += "</script>\n";

     ClientScript.RegisterClientScriptBlock(this.GetType(), "clientscript", strscript);
                 }

转载于:https://www.cnblogs.com/lljinz/archive/2011/04/02/2002915.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值