AddToBasket Validator

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
sloDavid
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 92
Joined: Thu Feb 25, 2010 12:34 pm

AddToBasket Validator

Post by sloDavid » Mon Sep 27, 2010 12:39 pm

I have products with product templates and required fields in those templates. When adding to the basket (in the store itself), if I fail to fill the form field, the validator properly catches it prior to submitting the postback. For unknown reasons though, the page doesn't stay put but scrolls immediately to the top of the screen (so it's not obvious to the user what's happening).

If the user scrolls down, they'll see the required field asterisk (*). I don't remember if it was always like this, but it's doing it now. Does anybody know why? Is there a way to get the page to just stay put? At the very least, does anybody know if this is this normal behavior for the BuyProductDialog?

dappy2
Commander (CMDR)
Commander (CMDR)
Posts: 114
Joined: Wed Jan 18, 2006 5:53 pm
Contact:

Re: AddToBasket Validator

Post by dappy2 » Mon Sep 27, 2010 1:22 pm

Are you using .Net validators? Add SetFocusOnError="true" and it will set the focus to the offending field.

sloDavid
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 92
Joined: Thu Feb 25, 2010 12:34 pm

Re: AddToBasket Validator

Post by sloDavid » Mon Sep 27, 2010 7:12 pm

I am using .Net validators. (They are specified in ProductHelper.BuildProductChoices(), which is called by BuyProductDialog's Page_Init().) I set the SetFocusOnError to true, but that didn't work. It still goes to the top of the page.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: AddToBasket Validator

Post by mazhar » Tue Sep 28, 2010 4:12 am

Read following thread
viewtopic.php?f=42&t=10944

sloDavid
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 92
Joined: Thu Feb 25, 2010 12:34 pm

Re: AddToBasket Validator

Post by sloDavid » Tue Sep 28, 2010 5:18 pm

Thank you. That pointed me in the right direction. The root problem is the same as described on StackOverflow: http://stackoverflow.com/questions/6991 ... ump-to-top. I have not yet decided my solution... it will probably be to completely excise the Validation Summary from the page, since I don't use it.

sloDavid
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 92
Joined: Thu Feb 25, 2010 12:34 pm

Re: AddToBasket Validator

Post by sloDavid » Tue Sep 28, 2010 5:32 pm

Yep. That did it. I simply commented-out the ValidationSummary from the BuyProductDialog, and the page stopped scrolling. Validation still works. Thanks again, mazhar!

And for anyone else who wants/needs to keep the ValidationSummary, there's another solution out there that looks promising, in addition to the StackOverflow link that I already posted. Below describes a hack that will scroll directly to the ValidationSummary:
http://forums.asp.net/p/999418/1494457.aspx#1491542

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: AddToBasket Validator

Post by mazhar » Wed Sep 29, 2010 4:53 am

BTW there could be one more thing and that is to simply move validation summary to page top. In this way validation errors will be visible always.

Post Reply