Dumb question about Message boxes

C

Coleen

I'm using MS .Net Version 7, using VB .Net working on a "simple" web page.
All I want to do is display a messagebox. I tried using Messagebox.Show,
and get an error that Messagebox has not been declared. I tried using
MsgBox (like we used in VB 6) but this throws application errors every time
I run it I get the error "It is in valid to show a modal or form when the
application is not running in UserInteractive mode. Specify the
ServiceNotification or DefaultDesktopOnly style to display a notice from a
service application" I tried Response.Write, which just puts the message in
the background of my web page, not popping up like a REAL MsgBox! Please
help with this, this should be SIMPLE!!! TIA

Coleen
 
N

Norman Yuan

It seems that you are talking about Web app. Do you really want to show a
MessageBox on the web server, while user sits in front of a web browser
thousands kilometers away? How does the user know a MessageBox pops up on
the web server? In Web app, if you want to nitify user something, you should
have the web server send back a page to user, either in the same browser
window or in a new browser window.

By the way, MessageBox is in System.Windows.Forms namespace, which is not
referenced in web app by default. That is why you get error "Not declared".
 
C

Coleen

What I am doing is writing validation for a Web form. If data is entered
incorrectly, I want a messagebox to notify the user the data type is
incorrect...I tried putting in the Name Space for System.Window, but that
did not work either. Ugh! This used to be simple! thanks for any/all of
your help.
 
C

Coleen

When I put System.Windows.Forms in the Namespace I get the blue squiggly
line with the message "Namespace or type 'forms' for the Imports
'System.Windows.forms' cannot be found. What's up with that? Usually, when
you put in the Namespace, the choices pop-up after you type the . but in
this case, Windows does not come up as one of the available choices under
System! How can I put in a Namespace when it is not available or supported?
 
J

Jan Tielens

If you are writing a web application (e.g. Webform), then the System.Windows
namespace is not available. This namespace is meant for WindowsForms
applications.

Jan
 
M

Michael Lang

When I put System.Windows.Forms in the Namespace I get the blue
squiggly line with the message "Namespace or type 'forms' for the
Imports 'System.Windows.forms' cannot be found. What's up with that?
Usually, when you put in the Namespace, the choices pop-up after you
type the . but in this case, Windows does not come up as one of the
available choices under System! How can I put in a Namespace when it
is not available or supported?

Adding a "using" or "Imports" statement at the top of the code file is not
the same as ading a reference. To add a reference use the project
explorer. Right-click on the "references" folder as select "Add
reference..." Then browse for "System.Windows.Forms".

When you create a "Windows Forms Application" in the new project wizard it
does this or you. On the other hand you should not be using windows forms
in a web application, which is why that reference is not made.

What you want is a scripting message box. It will appear on the client
side of the web page. I have not made one in ASP.NET, but it won't be that
different from ASP.

See the following link. It shows how to do it with both Javascript and
VBscript:

http://www.javascriptkit.com/javatutors/vbalert.shtml

Michael Lang
 
C

Coleen

Thank you! I was just informed by one of my co-workers that I would need to
do my form validation using JavaScript - unfortunately I have NO knowledge
of JavaScript, so this is good news that I can do it in VB Script! Thanks
:)
 
S

Scott M.

But you really shouldn't do it in VBScript, since Netscape browsers don't
support VBScript.

In a nutshell Colleen, it wasn't that different in Classic ASP. You
couldn't ask for a msgbox() in classic ASP either because message boxes are
not produced by the server, they are produced by the browser. Since
server-side code executes, well at the server, asking for a messagebox is
out of the question. All requests for messageboxes/alerts must be made at
the client level.
 
C

Coleen

Which is fine and dandy, if you know JavaScript, but I don't! So I am
looking for an alternative. If I have to use JavaScript, then I have to,
but do you have any suggestions for a VERY beginner? I have no idea even
where to start. Where do I write the code? In the aspx portion, or the
code behind? I haven't a clue... Thanks for any suggestions :)
 
S

Scott M.

See my other post...

JavaScript IS the answer you are looking for. In today's world of web
development, JavaScript is a must know.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top