views:

53

answers:

1

i have a doubt on how to show a popup???`

   if (machineID.Count != 0)
            { 
           checkMachineGrpState(machineID);
            }

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

Ok now what im am doing in else statement is signing out the user and sending him back to the log out page.... I need to how him some pop up message that he is being signed out i cant figure out how to do that... i tried messagebox but it wont work with servver and client side.. I want to use AJAX but dont know how... any suggestions.... thanks

+1  A: 

There are a couple of different ways you can go about this. Here's a simple example.

Your Default.aspx page will need to display the message to the user when they've logged out, so you might want a way to distinguish when you want to show the message. You could add a query string param to your redirect, like:

Response.Redirect("~/Default.aspx?ShowLogout=true");

Now on your Default.aspx page, you have a number of options. You could simply show a hidden control on the page, or write out some Javascript to show an alert box:

if (!String.IsNullOrEmpty(Request.QueryString["ShowLogout"]))
                ClientScript.RegisterStartupScript(this.GetType(), "LogoutMsg", "<script>alert('You have been logged out.');</script>");

This will simply write out a script tag that runs when the user views the page. From here, you can make it more elegant by showing the user a better dialog box. For example, you could use jQuery to create a nice looking dialog box, and call the Javascript function to show it rather than calling alert in my example.

wsanville
i wish to show something befre he goes to the logout page.....cant i use the ajax pop upbx or something... still appreciate ur help.. thanks
If your logout check is in the code behind of one of you pages, then you really don't have any options other than show the box before the page posts back or show it on the default.aspx page. On the other hand, you could have Javascript method poll a service in your app (service that requires Session) that does the logout check. Then you would know when the user has been logged out and can react to it within your Javascript.
wsanville