asp.net后台弹出对话框

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/dyh12345678/article/details/82983098

后台根据判断弹出对话框

前台页面
html code
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Button ID="btnCallBack" runat="server" Text="回发并弹出confirm" OnClick="btnCallBack_Click" />
    <asp:Button ID="btnHid" runat="server" OnClick="btnHid_Click" Width="0px" />
    <asp:HiddenField ID="hid" runat="server" />
    </div>
    </form>
</body>
</html>

后台代码

protected void btnCallBack_Click(object sender, EventArgs e)
    {
        //do sth
        string js = string.Format("document.getElementById('{0}').value=confirm('是否确认?');document.getElementById('{1}').click();", hid.ClientID,btnHid.ClientID);
        ClientScript.RegisterStartupScript(GetType(), "confirm", js, true);
    }
    protected void btnHid_Click(object sender, EventArgs e)
    {
        string result = hid.Value.ToLower() == "true" ? "是" : "否";
        Response.Write(string.Format("您选择的是{0}",result));
    }
展开阅读全文

没有更多推荐了,返回首页