MsgBox


J

Jim in Arizona

I wanted to make a pop up box to verify a choice to delete a database
record, so I tried this code:

Dim Result As MsgBoxResult
Result = MsgBox("Are You Sure?", MsgBoxStyle.OkCancel, "Sure?")
If Result = MsgBoxResult.Ok Then
Else
End If

The error I got was:

Showing a modal dialog box or form when the application is not running
in UserInteractive mode is not a valid operation. Specify the
ServiceNotification or DefaultDesktopOnly style to display a
notification from a service application.

I dont understand this message. How would I make a message box like this
work? I figured doing the code may render some kind of javascript on the
client side but I guess not (I was hopeful though).
 
Ad

Advertisements

J

John Timney \(MVP\)

You have to use javascript. Your in the web world now.

Take a look at teh code below.

Regards

John Timney (MVP)
http://www.johntimney.com


html>
<head>
<script language="VB" runat="server">
'Sub Page_PreRender()
Sub Page_Load( sender as Object,e as EventArgs)
'Form the script that is to be registered at client side.
Dim scriptString as String = "<script language=JavaScript> function
DoClick() {"
ScriptString += "var truthBeTold = window.confirm('Click OK to continue.
Click Cancel to stop.');"
ScriptString += "if (truthBeTold)"
ScriptString += "window.alert('Welcome to MVP World!');"
ScriptString += "else window.alert('Bye from MVP World!');}<"
scriptString += "/"
scriptString += "script>"
If(Not IsClientScriptBlockRegistered("clientScript"))
RegisterClientScriptBlock("clientScript", scriptString)
End If
End Sub
</script>
</head>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>
 
Ad

Advertisements

J

Jim in Arizona

John said:
You have to use javascript. Your in the web world now.

Take a look at teh code below.

Regards

John Timney (MVP)
http://www.johntimney.com


html>
<head>
<script language="VB" runat="server">
'Sub Page_PreRender()
Sub Page_Load( sender as Object,e as EventArgs)
'Form the script that is to be registered at client side.
Dim scriptString as String = "<script language=JavaScript> function
DoClick() {"
ScriptString += "var truthBeTold = window.confirm('Click OK to continue.
Click Cancel to stop.');"
ScriptString += "if (truthBeTold)"
ScriptString += "window.alert('Welcome to MVP World!');"
ScriptString += "else window.alert('Bye from MVP World!');}<"
scriptString += "/"
scriptString += "script>"
If(Not IsClientScriptBlockRegistered("clientScript"))
RegisterClientScriptBlock("clientScript", scriptString)
End If
End Sub
</script>
</head>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>

Thanks John. I'll make good use of it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

MsgBox in ASP.NET? 1
MSGBOX PROBLEM 3
Enterprise Logging does nothing on server 5
msgbox 4
Weird ASP.NET 2.0 Error 1
msgbox 4
MsgBox Error 1
Window Services XML Export Error 1

Top