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?
AddToBasket Validator
Re: AddToBasket Validator
Are you using .Net validators? Add SetFocusOnError="true" and it will set the focus to the offending field.
Re: AddToBasket Validator
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.
Re: AddToBasket Validator
Read following thread
viewtopic.php?f=42&t=10944
viewtopic.php?f=42&t=10944
Re: AddToBasket Validator
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.
Re: AddToBasket Validator
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
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
Re: AddToBasket Validator
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.