01.
Imports
System.Web
02.
Imports
System.Text
03.
Imports
System.Web.UI
04.
05.
Namespace
MyTools
06.
Public
NotInheritable
Class
Alert
07.
Public
Shared
Sub
ShowMessage(
ByVal
message
As
String
)
08.
09.
Dim
cleanMessage
As
String
= message.Replace(
"'"
,
"\'"
)
10.
Dim
script
As
String
=
"<script type="
"text/javascript"
">alert('"
& cleanMessage &
"');</script>"
11.
12.
13.
Dim
page
As
Page = TryCast(HttpContext.Current.CurrentHandler, Page)
14.
15.
16.
If
page IsNot
Nothing
AndAlso
Not
page.ClientScript.IsClientScriptBlockRegistered(
"alert"
)
Then
17.
page.ClientScript.RegisterClientScriptBlock(
GetType
(Alert),
"alert"
, script)
18.
End
If
19.
End
Sub
20.
End
Class