如何在C#Asp.Net上执行退出按钮代码? [英] How Do I Do A Exit Button Code On C# Asp.Net?

查看:135
本文介绍了如何在C#Asp.Net上执行退出按钮代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用确认框在C#asp.net中执行退出按钮,我弹出确认框,但我无法退出,请帮助。



这是我到目前为止所得到的:



I am trying to do an Exit button in C# asp.net with a confirmation box, I got the confirmation box to pop up, but I can not exit, please help.

This is what I got so far:

protected void btnExit_Click(object sender, EventArgs e)
        {

            ClientScriptManager CSM = Page.ClientScript;
            if (!ReturnValue())
            {
                string strconfirm = "<script>if(!window.confirm('Are you sure?')){window.location.href='Default.aspx'}</script>";
                CSM.RegisterClientScriptBlock(this.GetType(), "Confirm", strconfirm, false);
                
            }
            
        }
        bool ReturnValue()

        {
            return false;
            
        }

推荐答案

protected void btnExit_Click(object sender, EventArgs e)
{

ClientScriptManager CSM = Page.ClientScript;
if (!ReturnValue())
{
string strconfirm = "<script type='text/javascript'>if(window.confirm('Are you sure?')){window.location.href='Default.aspx'}</script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), "Confirm", strconfirm, false);

}

}


你可以参考这个链接



http://forums.asp.net/p/1310365/2578709.aspx #2578709 [ ^ ]



希望它会有所帮助..
You can refer this link

http://forums.asp.net/p/1310365/2578709.aspx#2578709[^]

Hope it will help..


这篇关于如何在C#Asp.Net上执行退出按钮代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆