By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,983 Members | 2,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,983 IT Pros & Developers. It's quick & easy.

Messagebox

P: n/a
Hi All,

I just want to display a message using msgbox() and I keep on getting this
error message.

It is invalid to show a modal dialog or form when the application is not
running in UserInteractive mode. Specify the ServiceNotification or
DefaultDesktopOnly style to display a notification from a service
application.

This error came from test.aspx.vb

Private Sub Img_OK_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles Img_OK.Click

If txt_Username.Text = "ABC" Then

Msgbox("Hello")

End If

End Sub

Why is wrong with this line? TIA
Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Larry,

You may not use msgbox to write to a HTML client application in the manner
that you are trying.

Use the response.write method just as you always have in asp development or
drag a label control on the webform and set the .text property to your
value.

"Larry Pits" <lp***@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi All,

I just want to display a message using msgbox() and I keep on getting this
error message.

It is invalid to show a modal dialog or form when the application is not
running in UserInteractive mode. Specify the ServiceNotification or
DefaultDesktopOnly style to display a notification from a service
application.

This error came from test.aspx.vb

Private Sub Img_OK_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles Img_OK.Click

If txt_Username.Text = "ABC" Then

Msgbox("Hello")

End If

End Sub

Why is wrong with this line? TIA

Jul 21 '05 #2

P: n/a
MessageBoxes are produced by the client. Because you are making a web
application, this means the browser. Your code, however, will run on the
server. This is why you can't use a MessageBox from server-side code in a
web app (always been that way).

You could substitute:

response.write("alert(yourMessageHere)")

for your MsgBox() line.

Also, in situations where you can use the MessageBox (Windows Applications),
you should now use the MessageBox class, rather than the MsgBox() function
from VB 6. The class is used with its shared "show" method as:

MessageBox.Show(args)

-Scott M.

"Larry Pits" <lp***@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi All,

I just want to display a message using msgbox() and I keep on getting this
error message.

It is invalid to show a modal dialog or form when the application is not
running in UserInteractive mode. Specify the ServiceNotification or
DefaultDesktopOnly style to display a notification from a service
application.

This error came from test.aspx.vb

Private Sub Img_OK_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles Img_OK.Click

If txt_Username.Text = "ABC" Then

Msgbox("Hello")

End If

End Sub

Why is wrong with this line? TIA

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.