By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,853 Members | 842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,853 IT Pros & Developers. It's quick & easy.

Inject items in ValidationSummary control?

P: n/a
First, a little background. I'm trying to forge ahead into ASP.NET 2.0.
I've dome many assemblies in C#, but I've yet to have to use ASP.NET.
I'm trying to forge ahead in getting some web/server controls created so
during a future conversion the work is already done for other programmers.

I've started created common controls used in various ecommerce
checkouts. For example, credit card validation, promo vcodes validation,
etc. Some sites use both, some sites use one. In ever case, they all
just do the right thing because their validation error messages go into
a ValidationSummary control. This is all well and good for server side
validation.

However, even if the server side validates user input, the backend
systems may still throw up errors about the data the user entered...like
the promo code has expired, the credit card is a private lable and has
options, etc, etc.
What I would like to do is inject those returned errors back into the
ValidationSummary component since they will be displayed the same way,
and the Page.IsValid would be True at that point. I have no clue where
to begin with such a task and am looking for pointers to the approach.

There could be in excess of 20 errors returned, so I didn't want to
create local validators that simply checked the return codes.

Any ideas?

Thanks,
-=Chris
Jul 25 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Jan
use a System.Web.UI.WebControls.CustomValidator and place your server
side validation code in the ServerValidate handler.

The client side validation checks will all be done first and if they
all pass the page will post back at which point the CustomValidators
will be run.

Hope that helps,

Jan

Jul 25 '05 #2

P: n/a
Jan wrote:
use a System.Web.UI.WebControls.CustomValidator and place your server
side validation code in the ServerValidate handler.

The client side validation checks will all be done first and if they
all pass the page will post back at which point the CustomValidators
will be run.

Hope that helps,

Jan

I'm already using CustomValidators. The problem is, if I use 1
CustomValidator to validate data with the backend system, I need to
stuff many different ErrorMessages into the ValidationSummary, not just
the single ErrorMessage for that CustomValidator. Even if I stuff
multiple LI HTML into the ErrorMessage property, it gets wrapped in a
single LI during Render.

-=Chris
Jul 25 '05 #3

P: n/a
Jan
Ah I see,

Well just create a class with a static boolean attribute that stores
it's data in Session[...] like ValidationFailed.

When you start processing the serverside validators set it false;
Then set it true if a custom validator fails.
And make sure that each validator only runs if ValidationFailed is
false

Hope that helps

Jul 26 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.