Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 725
  • Last Modified:

Validation Summary vs Javascript

Hi, I'm using a validation summary. When I set the show msgbox property to true, it'll show the msgbox but only if the page submits. Any way to call the validationsummary from a custom javascript function without submitting the page (static msgbox will do) ? If so, what would be code, thanks.
0
GPSAddict
Asked:
GPSAddict
  • 7
  • 6
2 Solutions
 
AsishRajCommented:
Do the validation in javascript...post you validation code and experts will be more than happy to help you
0
 
GPSAddictAuthor Commented:
Wouldn't it be easier to let .NET handle all the error processing and simply call the summary in js ? That way I have a single line of code to write...It is possible or not ?

If not, I guess I'd need a generic function that checks if some fields (texboxes, radios, checkboxes and listboxes) are null or empty (with trim).

Oh and the fields are set to run on server.

Thanks
0
 
AsishRajCommented:
try enabling EnableClientScript="true" in Validation Summary

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
GPSAddictAuthor Commented:
I know that but it still requires the form to submit...
0
 
AsishRajCommented:
if there is an error it does not post back. - this is the function of  EnableClientScript="true

the link i gave you, it does not postback if there is an error.
0
 
GPSAddictAuthor Commented:
It still submits the form...
0
 
AsishRajCommented:
this is something that you should read

Client-Side Validation  The validation controls always perform validation checking in server code. However, if the user is working with a browser that supports DHTML, the validation controls can also perform validation using client script. With client-side validation, any errors are detected on the client when the form is submitted to the server. If any of the validators are found to be in error, the submission of the form to the server is cancelled and the validator's Text property is displayed.  This permits the user to correct the input before submitting the form to the server.  Field values are revalidated as soon as the field containing the error loses focus, thus providing the user with a rich, interactive validation experience.  

  Note that the Web Forms page framework always performs validation on the server, even if the validation has already been performed on the client.  This helps prevent users from being able to bypass validation by impersonating another user or a preapproved transaction.  

  Client-side validation is enabled by default.  If the client is capable, uplevel validation will be performed automatically. To disable client-side validation, set the page's ClientTarget property to "Downlevel" ("Uplevel" forces client-side validation). Alternatively, you can set an individual validator control's EnableClientScript property to "false" to disable client-side validation for that specific control.  

Source: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/validation/default.aspx

there is a difference from postback and form submit on the client side
0
 
AsishRajCommented:
This is an article u must read to understand the info indept

Taming the ASP.NET Validation Summary Control -
http://www.asp101.com/articles/manu/validationsummary/default.asp
0
 
GPSAddictAuthor Commented:
Thanks for links, it helps me understand all of the validators behavior. However, it is still unclear to me how I could, upon a button click,successfully show the content of the validatorsummary msgbox without submitting the page ! In your links I found out what event to use server-side but I have no idea how to retrieve the validatorsummary message (unless it is impossible to do so without submitting ?) Any ideas ? Thanks
0
 
GPSAddictAuthor Commented:
Please note I am not trying to retrieve the text property of validators but the message that would be returned by the validatorsummary with a msgbox (I want to use a msgbox also). Thanks
0
 
AsishRajCommented:
Please post your Validation Summary Code. so that i can see whats happening
0
 
GPSAddictAuthor Commented:
Nevermind, I'll do the complete validation in js. Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now