Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 27th, 2007, 09:31 AM
Authorized User
 
Join Date: Jul 2007
Posts: 24
Thanks: 1
Thanked 0 Times in 0 Posts
Default Message box in ASP.NET

Hi, to all the users. I want to use a message box in ASP.NET web app such that when he clicks a logout button and message prompts to ask him do he really want to logout. I embedded javascript in with VB.NET but it won't works. Can anyone give suggestion for the same..

private Sub ShowMessage(dim message as String)
   MessageBox Script
   Dim scriptString As String = "<script language=JavaScript>"
   String scriptString = "<script language=JavaScript>";
   scriptString += "alert('" + message + "')"
   scriptString += "</script>"
   'if(!this.IsStartupScriptRegistered("MessageBox"))
   Page.RegisterStartupScript("ShowMessage", scriptString)
   End Sub
   Private Sub imgLoggedout_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgLoggedout.Click
   ShowMessage("Do you really want to logout")
   'MsgBox("Do you really want to logout", MsgBoxStyle.OKCancel = MsgBoxStyle.OKOnly, Session("userlogedin") = "No")
   Session("userlogedin") = "No"
   Response.Redirect("Logon.aspx")
End Sub
 
Old July 27th, 2007, 10:22 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can do this like this:

Somewhere in your page so it always runs (maybe Page_Load()) add this code:

imgLoggedout.Attributes("onclick") = "return confirm('Do you really want to log out?');"

This will fire off the "confirm" client side method which gives you the OK/Cancel dialog. If the user hits cancel, the page is not posted and thus the logout code on the server doesn't run.

-Peter
 
Old July 27th, 2007, 10:33 AM
Authorized User
 
Join Date: Jul 2007
Posts: 24
Thanks: 1
Thanked 0 Times in 0 Posts
Default

ya it works, the message box is displayed. But on clicking ok button it is redirecting to the same page. I want it to redirect to logon.aspx page which is the default page of my web application.

 
Old July 27th, 2007, 10:41 AM
Authorized User
 
Join Date: Jul 2007
Posts: 24
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanx, its running fine..






Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Message Box Nilesh Barhate Classic ASP Basics 1 July 25th, 2005 01:00 PM
Message Box In ASP Nilesh Barhate Classic ASP Basics 0 July 20th, 2005 06:07 AM
Message box in ASP shazia1 VS.NET 2002/2003 1 June 25th, 2005 03:01 AM
Sending a message in asp.net eresina General .NET 3 April 13th, 2005 09:16 AM
Simple ASP.NET message box with VB janicen General .NET 1 February 24th, 2005 03:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.