Messagebox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Larry Pits

    #1

    Messagebox

    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 ServiceNotifica tion or
    DefaultDesktopO nly style to display a notification from a service
    application.

    This error came from test.aspx.vb

    Private Sub Img_OK_Click(By Val sender As System.Object, ByVal e As
    System.Web.UI.I mageClickEventA rgs) Handles Img_OK.Click

    If txt_Username.Te xt = "ABC" Then

    Msgbox("Hello")

    End If

    End Sub



    Why is wrong with this line? TIA


  • Chris Smith

    #2
    Re: Messagebox

    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" <lpits@hotmail. com> wrote in message
    news:%230ve2L63 DHA.1924@TK2MSF TNGP10.phx.gbl. ..[color=blue]
    > 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 ServiceNotifica tion or
    > DefaultDesktopO nly style to display a notification from a service
    > application.
    >
    > This error came from test.aspx.vb
    >
    > Private Sub Img_OK_Click(By Val sender As System.Object, ByVal e As
    > System.Web.UI.I mageClickEventA rgs) Handles Img_OK.Click
    >
    > If txt_Username.Te xt = "ABC" Then
    >
    > Msgbox("Hello")
    >
    > End If
    >
    > End Sub
    >
    >
    >
    > Why is wrong with this line? TIA
    >
    >[/color]


    Comment

    • Scott M.

      #3
      Re: Messagebox

      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(yourMess ageHere)")

      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" <lpits@hotmail. com> wrote in message
      news:%230ve2L63 DHA.1924@TK2MSF TNGP10.phx.gbl. ..[color=blue]
      > 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 ServiceNotifica tion or
      > DefaultDesktopO nly style to display a notification from a service
      > application.
      >
      > This error came from test.aspx.vb
      >
      > Private Sub Img_OK_Click(By Val sender As System.Object, ByVal e As
      > System.Web.UI.I mageClickEventA rgs) Handles Img_OK.Click
      >
      > If txt_Username.Te xt = "ABC" Then
      >
      > Msgbox("Hello")
      >
      > End If
      >
      > End Sub
      >
      >
      >
      > Why is wrong with this line? TIA
      >
      >[/color]


      Comment

      Working...