Hi:
I have a little bit of issue displaying message boxes. Sometimes the message box shows up on the same page that I am on (this is what I wnat) and sometimes it shows up on a blank page (this is not what I want). I just like to make sure that my Msg Box pops up on the same page that I am working on. Here is my class and how I call my class:
Imports
Microsoft.VisualBasic
Imports
System.Windows.FormsPublic Class PublicMessageBox
Inherits System.Web.UI.Page
Public Sub UserMsgBox(ByVal sMsg As String, ByRef inputPage As System.Web.UI.Page)
Dim sb As New StringBuilder()Dim oFormObject As System.Web.UI.Control
sMsg = sMsg.Replace(
"'", "\'")sMsg = sMsg.Replace(Chr(34), "\" & Chr(34))
sMsg = sMsg.Replace(vbCrLf,
"\n")
sMsg =
"<script language=javascript>alert(""" & sMsg & """)</script>"sb = New StringBuilder()
sb.Append(sMsg)
For Each oFormObject In inputPage.Controls
If TypeOf oFormObject Is HtmlForm Then
' Add the javascript after the form object so that the ' message doesn't appear on a blank screen.End SuboFormObject.Controls.AddAt(oFormObject.Controls.Count, New LiteralControl(sb.ToString()))
Exit For
End If
Next
End Sub
- Here how I use my class:
Dim
clsMsg As PublicMessageBox = New PublicMessageBox
clsMsg.UserMsgBox(
"There is no data available.", Me)