tags:

views:

57

answers:

3

i wanna to show a message box but i prefer to be server side ,i wanna to have full control over it,i mean the number of buttons, the icon .... etc like windows application.

the problem when add reference to system.windows.forms and use it , when publish the site on the server i have an error , i can't remember exactly , but when remove all my messages every thing becomes ok.this problem appears even with summary validation when i wanna to be shown as a message box rather than list. i wanna solution to this problem ,please.

+2  A: 

Thick client messagebox appears on the machine where the code is running. What would happen if you didn't get the error is that a messagebox would appear on the server console in your server room and your program would stop processing; to the user, it would appear crashed.

You don't want that.

Fortunately Microsoft, like a kind parent, knows that as well, and when it detects a messagebox being used in an ASP program, it blows up. Think of it as a timeout for playing in the street.

But a step up from that:

Messageboxes are the worst for the user. Avoid them at all costs. They suck.

Seriously. EVERY newbie programmer misses on this; learn early, whether you're in thick client or web. They stop the users in their tracks, they have no choice but to click OK. That's why they only pop up for spam pages and obnoxious ad sites. Because those suck, too. And they mean to annoy you.

Do you mean to annoy your users? When not go back to MS-Basic on an IBM-PC or AT, and just your INPUT statements all in a row. That will only give the user one thing to do, to. Real GUIs avoid that and let the user decide where to click - even when the users has just screwed up.

You want to correct your users' errors with a red message by the error'd field, and/or a very obvious warning box right where the data entry area would be (shifting the data entry area down).

You could have a normally blank hidden field in ASP, only put a message in it that you want to show in a messagebox, and have client-side code check for a value and pop up a messagebox. But you are probably creative enough to solve a problem without messageboxes though.

the reason you don't see them a lot is because they suck, they make your website suck, and you don't need them. And modern web designers know this.

Have a hidden panel in your webform specifically designed for error messages or important messages. Show it when you would normally show a messagebox. And/or use the built-in webforms validation tools. Or just show the entire message on a page by itself

There are other right ways to do this, too; some availabe libraries even put a message-box-looking fake box up over the webpage like a rollover ad (note my comparison: this method is obnoxious too as it constrains the user).

Sorry for the tone of this answer. It is meant to drive home the point that too many programmers take too long to learn for themselves:

MESSAGEBOXES SUCK!

FastAl
I hope my kids never read this.
FastAl
Low class whoever DV'd the asker. I'd like to comment on the first few web apps you designed/wrote.
FastAl
+1, but your rant is a bit excessive. :) Your first paragraph is spot-on though.
Kirk Woll
thank u so much FastAl for your detailed answer,really i appreciate your help,u are right this is my idea to show messages when there is a required field or specific check, to alert the user rather than on the page ,it may not see the alert, but what is the best alternative to message boxes in web application ,i can do ,the user can notice and has a nice appearance.
@just-name: I would suggest this. For a messagebox that applies to the whole page: use a hidden div. In WebForms this means (I think) just dropping in a panel and setting it by default to hidden. Put your message in controls there, you can make it look fancy and add graphics (e.g., cute little exclamation point in a triangle; provide options user can pick and post back). When there is a case you want to do a messagebox, show it, then let ASP send the page. You CAN'T EVER stop your program and have it wait for a response like thickclient (sorry, a web limitation!).
FastAl
A: 

Use logging instead of a messagebox.

Brent Arias
He is asking why when removing all invocations to **System.Windows.Forms** that his **ASP.NET** app suddenly starts working. This answer does not address that.
Kirk Woll
+1  A: 

If you've come from a Winforms background you're in for a surprise. The web architecture is very different and although this seems like a trivial and valid thing in WInforms. This is a very bad move for web app.
I won't even try to suggest how to do it. I'll only say that this is not a good choice because it'll cause your form to postback just to show a message which is a "sin" in web programming. Read up a bit on web and disconnected arch. and you'll understand why this is frowned upon. If possible, use javascript alerts or show/hide div for messages maybe.

Sidharth Panwar
+1 for the show/hide div. But a javascript alert is a messagebox. And messageboxes, as you know, well, they.. Um, er.. How do I feel about messageboxes? Hmmm.. Un-plus one for the alert.
FastAl
Well, if he's trying to actually add a reference to System.Windows.Forms, the surprise he's in for is much bigger than you're implying.
Kirk Woll