Reputation: 11423
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.
Upvotes: 0
Views: 186
Reputation: 6279
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.
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:
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.
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:
Upvotes: 2
Reputation: 4654
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.
Upvotes: 1