Yes! Msgbox in ASP.NET: No way to show MsgBox in ASP.NET, since MsgBox resides on Client side and ASP.NET on server one. I wrote this small code to simulate it in JS. Enjoy - Oded '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function MsgBoxJS(ByVal strMessage As String) As Long '* Simulate MsgBox to run from ASPX '* strMessage: Text to display '* Return: -1 if faild: Enjoy, Oded Dim STR_Buider As New System.Text.StringBuilder Try If InStr(strMessage, "'") Then Throw New
System.Exception("Apostrophe Exception..") STR_Buider.Append("<script>") STR_Buider.Append(Environment.NewLine) STR_Buider.Append("alert('" & strMessage & "');") STR_Buider.Append(Environment.NewLine) STR_Buider.Append("</" + ?script>") Page.RegisterStartupScript("MsgBoxJS",
STR_Buider.ToString()) Return 0 Catch ex As Exception Return -1 End Try End Function
Question for Odedyh! I have put your code in my solution but it doesn't work. An error is at the line: Page.RegisterStartupScript("MsgBoxJS", STR_Buider.ToString()) Did I forget to include something? P.S. I am a freshman in .net
markoc hi, This code works just fine. please check Requirements: Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family for the .Net.... If you choose web application... and have regular references to: system, system.web... Oded
Added references are: Imports System Imports System.Text Imports System.Security.Cryptography Imports System.Web.Security Imports System.Data.SqlClient Imports System.Collections Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports
System.Web.UI.HtmlControls I have a compile time problem. The build error list shows the following text: "Reference to a non-shared member requires an object reference." I've put the code within a class in a vb module.
Maybe he wants to add buttons like "YES" "NO", "OK" "Cancel", etc... Which is available in VBScript, However I only know to type of function like this in JS...
Alert the one you are using and confirm which will show an "OK" and "Cancel" Button that will return true if "OK" button is click otherwise return false. Is there other msgbox like function in JS other than
alert() and confirm? :) Regards.
The most wasted day is that in which we have not laughed.
Odedyh
Member
40 Points
8 Posts
MsgBoxJS: MsgBox in ASP!!!
Jul 23, 2003 01:35 PM|LINK
jpartley
Member
25 Points
5 Posts
Re: MsgBoxJS: MsgBox in ASP!!!
Jul 25, 2003 01:51 AM|LINK
Yahoo messenger please :-)
markoc
Member
15 Points
3 Posts
Re: MsgBoxJS: MsgBox in ASP!!!
Jul 25, 2003 10:42 AM|LINK
Odedyh
Member
40 Points
8 Posts
Re: MsgBoxJS: MsgBox in ASP!!!
Jul 27, 2003 10:42 AM|LINK
SreedharK
All-Star
18571 Points
3119 Posts
MVP
Re: MsgBoxJS: MsgBox in ASP!!!
Jul 27, 2003 05:35 PM|LINK
http://www.w3coder.org
weblog http://weblogs.asp.net/skoganti
markoc
Member
15 Points
3 Posts
Re: MsgBoxJS: MsgBox in ASP!!!
Jul 28, 2003 06:49 AM|LINK
markoc
Member
15 Points
3 Posts
Re: MsgBoxJS: MsgBox in ASP!!!
Jul 28, 2003 08:35 AM|LINK
jpartley
Member
25 Points
5 Posts
Re: MsgBoxJS: MsgBox in ASP!!!
Jul 30, 2003 03:41 AM|LINK
Yahoo messenger please :-)
Odedyh
Member
40 Points
8 Posts
Re: MsgBoxJS: MsgBox in ASP!!!
Jul 30, 2003 11:06 AM|LINK
new2ASPnet
Member
700 Points
140 Posts
Re: MsgBoxJS: MsgBox in ASP!!!
Aug 01, 2003 06:54 AM|LINK
V i r g i l R e b o t o n