locked
display a message box in a vb.net web application

    Question

  • How do I get this to work on the client computer in a web application :

    MessageBox.Show(OnlineRepairListBox.SelectedItem.Text, "LEN Record Selected is :", _

     

    MessageBoxButtons.OK, MessageBoxIcon.Exclamation, _

     

     MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification)

    The message box appears on the server - I understand why, but I know there is a way to get this to work on the client.

    Does anyone have any code as an example?


    carl

    Tuesday, June 01, 2010 3:54 PM

Answers

  • I actually found that you can code this on the .ASP VB server side:

    anyvariable can be a string or integer which is added into the message.

     

    Dim message As String = "MESSAGE LINE ONE : " + anyvariable & "\n" & "MESSAGE LINE TWO"

     

    Dim script As String = "<script type='text/javascript' defer='defer'> alert('" + message + "');</script>"

    ClientScript.RegisterClientScriptBlock(

    Me.GetType(), "AlertBox", script)

     

      

    I just typed the above code in within the buttonclick VB part at the very end of the button click routine after I had updated the SQL server database. The message displays on the client side. The only thing I do not like is that it clears the screen, displays the message , user then clicks ok and then the message goes away and the screen is re-displayed.

     

     

    • Marked as answer by Carl2010 Thursday, June 24, 2010 4:05 PM
    Thursday, June 24, 2010 4:05 PM

All replies

  • You'd need to send client-side script to the client machine in order to display a message box on the client machine.  Another way would be to render a DIV (or other block element) to display a popup style window to show the message.  In either case, client-side script would be required for what you want.

    • Marked as answer by Martin_XieModerator Tuesday, June 08, 2010 8:30 AM
    • Unmarked as answer by Carl2010 Thursday, June 24, 2010 4:03 PM
    Tuesday, June 01, 2010 5:00 PM
    • Marked as answer by Martin_XieModerator Tuesday, June 08, 2010 8:30 AM
    • Unmarked as answer by Carl2010 Thursday, June 24, 2010 4:03 PM
    Wednesday, June 02, 2010 4:50 AM
  • I actually found that you can code this on the .ASP VB server side:

    anyvariable can be a string or integer which is added into the message.

     

    Dim message As String = "MESSAGE LINE ONE : " + anyvariable & "\n" & "MESSAGE LINE TWO"

     

    Dim script As String = "<script type='text/javascript' defer='defer'> alert('" + message + "');</script>"

    ClientScript.RegisterClientScriptBlock(

    Me.GetType(), "AlertBox", script)

     

      

    I just typed the above code in within the buttonclick VB part at the very end of the button click routine after I had updated the SQL server database. The message displays on the client side. The only thing I do not like is that it clears the screen, displays the message , user then clicks ok and then the message goes away and the screen is re-displayed.

     

     

    • Marked as answer by Carl2010 Thursday, June 24, 2010 4:05 PM
    Thursday, June 24, 2010 4:05 PM