Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 635237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:22:58+00:00 2026-05-13T20:22:58+00:00

how to show the alertbox first and then log out if (machineID.Count != 0)

  • 0

how to show the alertbox first and then log out

if (machineID.Count != 0)
            {

                checkMachineGrpState(machineID);
        else
                {
                    Response.Write("<script>alert('You are being logged out')</script>");

                   GoSignOut();
                }
    }

 private void GoSignout()
    {
        FormsAuthentication.SignOut();
        Session.Abandon();
        Response.Redirect("~/Default.aspx");
    }

here if i dont call the GosignOut function i can see the alert box but the moment i put call the signout it does not show me the alertbox and simply signs out

So i was thinking if there is a way i can see the alertbox first and then when i press OK it should call signout function in my code behind… thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:22:58+00:00Added an answer on May 13, 2026 at 8:22 pm

    use the clientclick of the server side button that calls this logout code, then return true

    e.g.

    <asp:Button id="button1" runat="server" OnClientClick="javascript:alert('You are being logged out');return true;" />
    

    edit re thought what you want. try this, I have not tested with the use of session.abandon and the Signout (which may force you to the login page)

    if (machineID.Count != 0)
                {
    
                    checkMachineGrpState(machineID);
            else
                    {
                       GoSignOut();
                      Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "<script>alert('You are being logged out');window.location.href='" + ResolveUrl("~/Default.aspx") + "';</script>");
                    }
        }
    
     private void GoSignout()
        {
            FormsAuthentication.SignOut();
            Session.Abandon();
        }
    

    if you need to allow the redirect to go to a page other than the login page (which is forced due to the SignOut) you can add something like the below to you web.config. I am not 100% sure you want to allow this as it would allow none authenticated users to access the page

    <location path="whateverpage.aspx">
        <system.web>
          <authorization>
            <allow users="*" />
          </authorization>
        </system.web>
      </location>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

why does this script show empty alert box. I am trying to use php
I'm trying to write a simple jQuery plugin to show an alert box (custom
I am trying to get the following form submission to show alert box if
Why does this call to setTimeout show the alert box but does not do
I want to show an alert box before form submission. If a user presses
I am trying to show a alert box in my app when numberformat exception
How to show javascript alertbox on button click event in asp.net webpage if textbox1.text=
I am showing a Alertbox after clicking a button. The Alert box is customised
I have an Alert method set in the main class. Which is then called
I want to show the value of the variable in Alert box so please

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.