Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

C#
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;
            
        }
Posted
Updated 7-Aug-14 20:13pm
v2
Comments
j snooze 7-Aug-14 17:54pm    
What do you mean it won't exit? It doesn't redirect to default.aspx?
[no name] 8-Aug-14 2:08am    
Please update the question with some more details...

C#
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);

}

}
 
Share this answer
 
You can refer this link

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

Hope it will help..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900