Learning While Aging

Display popup error with ASP.NET validators (Part one)

I have seen several times that some developers use their own JavaScrit functions to validate user input, such as empty input, input format, etc. When asked why not using the built-in ASP.NET validator controls, their answer surprised me: I want to have a popup for displaying all the errors, so I use JavaScript alert function.

Actually, it is when the ValidationSummary control comes in handy. The ValidationSummary control has a property called ShowMessageBox, its default value is False. When it is set to True, hurray, a popup message box (just like JavaScript alert) appears when the validation fails.

Here is the code for the ValidationSummary:

<asp:ValidationSummary ID="valSummary" runat="server" DisplayMode="List"
           ShowMessageBox="True" ShowSummary="False" />

 Very simple, right?

Happy programming!

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Close Bitnami banner
Bitnami