+ -
当前位置:首页 → 问答吧 → ASP.NET关于msgbox弹框

ASP.NET关于msgbox弹框

时间:2011-12-07

来源:互联网

页面上有一个按钮Button3
一个Textbox框 TextBox1


下面这句没问题,能实现根据TextBox1上填写的内容进行弹框
if(!Page.IsPostBack)


Button3.Attributes.Add("onclick","return confirm('你确定要对'+document.getElementById('" + TextBox1
.ClientID + "').value+'执行操作吗?')");




但是我想实现按下Button3按钮后弹出
(你确定要对'+document.getElementById('" + TextBox1
.ClientID + "').value+'执行操作吗)对话框,
如果在弹出的对话框中选择确定,那么跳转到A.aspx页面,
如果在弹出的对话框中选择取消,那么跳转到B.aspx页面,
这样的话代码该如何写呢?

作者: scorpio78787   发布时间: 2011-12-07

JScript code
function CheckMethod() { 
            
            var txt_text=document.getElementById('TextBox1').value;
            if (confirm('你确定要对' + txt_text + '进行操作么')) {
                window.location='A.aspx';

            }
            else {
                window.location='B.aspx';
            }
        }

HTML code
<asp:Button ID="Button1" runat="server" Text="Button"  
        OnClientClick="return CheckMethod();" onclick="Button1_Click"/>

作者: Return_false   发布时间: 2011-12-07

热门下载

更多