Forum Moderators: open

Message Too Old, No Replies

display alert box in asp.net application

         

zerocode

5:55 am on Sep 30, 2005 (gmt 0)

10+ Year Member



i have a problem in validating a asp .net form
having server controls. when i click a submit button it
should display a alert box saying that a required field is missing. this should be done without using javascript.
if the value is empty it should display an error message
else welcome message in a alert box.

can anyone help me on this.

mrMister

10:29 am on Sep 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



should display a alert box saying that a required field is missing. this should be done without using javascript.

Done without using JavaScript? What do you want to use?

zerocode

11:34 am on Sep 30, 2005 (gmt 0)

10+ Year Member



i want to use a server side script C#
and display a message box

mattglet

11:34 am on Sep 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unless I'm missing something, there is no way to do it without JavaScript. The alert box that you see is a client-side event, not a server side.

mrMister

2:11 pm on Sep 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, you're not missing something.

I've noticed more and more of this since .Net started to increase in popularity. It's a problem with Microsoft's marketing. They push ASP.Net to Application Developers and infer that making a Web Application is just the same as making a Windows Application. However you're going to come unstuck pretty quickly unless you do some background reading regarding Web Development.

Easy_Coder

7:01 pm on Sep 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



zerocode take a look at the RequiredFieldValidators. You just need to bolt them onto the controls that need validating.

TheNige

8:57 pm on Sep 30, 2005 (gmt 0)

10+ Year Member



exactly. And if you use the ValidationSummary control it has the option to create the alert box without you having to code anything.

If you want to do it another way, one idea is to use some dhtml to creat a floating div that would contain your error messages. You'd have to fill the contents of that div on the postback and then set the visibility of the div and place it where you want on the screen....to much work in my opinion.