Messagebox

  • Thread starter Thread starter Chris Smith
  • Start date Start date
C

Chris Smith

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.
 
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
 
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.
 
alternatively, use some client side script to check the value of a hidden
field when the form is loaded into the browser and display the contents (if
any) in an Alert.
 
Back
Top