Problem solve Get help with specific problems with your technologies, process and projects.

In ASP.NET, how do you create a popup window from the VB class generated from the page class?

I am developing an ASP.NET application. I have a form that I designed using the WEB controls. After collecting information from the user, like Social Security number and name, I add a record to a database. The record is added in the VB code for the on-click.

If there is an error with the database, or if a duplicate record is going to be added, I want to display a popup menu on the client side. The MessageBox.show is a server class (as I understand it) and would not work for the client side. How do you put up a popup window from the VB class generated from the page class?
MessageBox is not a server class, it's a Windows Forms class, and as such it can't be used in ASP.NET. On the client-side you can only use scripting. The proper way of doing what you want would be:

//After failing to insert record
Page.RegisterStartupScript("<script language=JavaScript>alert('Record 
was not inserted!');</script></pre>

That line will cause the script block to be placed at the bottom of the page and be executed as soon as the page has finished loading. There are several other RegisterXXX methods to emit client-side code from within your server side code.

Dig Deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.