Hi,

I'm having a little trouble about message box,
Since the website has been deployed in the IIS, the msgbox won't work anymore,
Now I need a new alternative to create a message box that could also have a validation,
something like

if msgbox("do you want to save this?", msgbox.yesno) = msgbox.yes then
'do some code
end if

Can anyone help me with this,

thanks

Dani AI

Generated

Short answer: you cannot use MsgBox/MessageBox from code running under IIS because those calls target a desktop UI on the server process — there is no interactive desktop for the worker process to show a dialog. As noted, the prompt must run in the browser (client-side), not on the server. was also right to point toward JavaScript dialogs; below are practical patterns you can apply in an ASP.NET (VB.NET) site.

Simple, built-in approach (yes/no)

Use the browser confirm() to block the postback when the user cancels. Put it on the button that causes the action:

<asp:Button ID="btnSave" runat="server" Text="Save"
    OnClick="btnSave_Click"
    OnClientClick="return confirm('Do you want to save this?');" />
Protected Sub btnSave_Click(sender As Object, e As EventArgs)
    ' Runs only if the user clicked OK in the client confirm dialog
    ' save logic here
End Sub

Showing messages from server code (after postback / inside UpdatePanel)

Emit client script from the server instead of trying to show a server dialog. For pages using UpdatePanel use ScriptManager.RegisterStartupScript; for plain pages ClientScript.RegisterStartupScript:

ScriptManager.RegisterStartupScript(Me, Me.GetType(), "info", "alert('Saved successfully');", True)

Better UX for production

Built-in alert/confirm are fine for quick checks, but use a custom modal (Bootstrap, jQuery UI, SweetAlert) for consistent styling and accessibility. Typical pattern: open modal on click, then on the modal’s Yes handler call __doPostBack or send an AJAX request to run the server action. Always escape/encode any server text you inject into script (use HttpUtility.JavaScriptStringEncode or similar) to avoid XSS.

Summary: follow ’s lead—move prompts to client-side. For simple yes/no use OnClientClick="return confirm(...)". For nicer dialogs or complex flows use a modal + postback/AJAX and emit scripts from the server when you must show a message after processing.

Recommended Answers

All 3 Replies

This should have been posted in the ASP.NET forum.

You can't use MsgBox nor MessageBox on the web.
What you can do is use javascript with a vbscript popup box.
Here is a solution:

Yes oxiegen correct, in web cant use msgbox. U can use alert in javascript.

Yes oxiegen correct, in web cant use msgbox. U can use alert in javascript.

Yup, I now understand, thanks for the help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.