Tuesday, June 30, 2009

Jump to validation summary on large page

Validation summary is an awesome ASP.NET control that can list validation messages in a collective way. Some time if you have validation summary at bottom of a large page, in this case if some validation error occurs the user has to scroll down towards the bottom to view the pages.

You can enhance user experience with Validation Summary control by automatically jumping to the error messages area when some error occurred. I am just explaining the steps to accomplish this.

In ASP.NET there is a client side variable Page_IsValid that indicates whether the page is currently valid or not. The validation scripts keep this up to date at all times. So all you need is to wrap your validation summary within some div and place some anchor upon that. Finally write a small piece of javascript that checks Page_IsValid and if its set to false simply jump to that named anchor. You can found a very helpful topic about ASP.NET Validation available here

1 comment:

Anonymous said...

Your Idea is Great. I tried it and is working good.

Thanks,
Shathar.