SmartNavigation and Determining If ValidationSummary Caught Any Errors

D

Dan Sikorsky

I'm using SmartNavigation and need to automatically scroll to the top of the
page when the ValidationSummary control catches errors and displays them, so
that the user can see the errors without having to manually scroll to the
top.

How can I determine if the ValidationSummary will display errors so that I
can issue a javascript window.scrollTo(0,0) or document.body.scrollTop = 0
(or something more appropriate) to automatically scroll to the top of the
page, thereby circumventing the SmartNavigation feature?
 
V

Viksi

You could add "#" to the address, or you could use java script to check for
the value of a hidden value field.
-Viksi
 
D

Dan Sikorsky

Could you clarify, with an informative example, what you mean by 'add # to
the address' and 'check for the value of a hidden field'?

In my .aspx file, I have:

<asp:validationsummary id="valValSummary" runat="server" headertext="There
are problems with the following fields:"></asp:validationsummary>

If no validation errors occur (no adjusting of the scroll position is
needed), then the user sees nothing. If validation errors exist, then the
user sees the headertext followed by each validation control's error message
in a bulleted list.

My first thought is to determine - on the server side during a postback - if
valValSummary is set to the headertext; how would this be done?
 
V

Viksi

Hello Dan,

Sorry for being to brief previously. You will be checking whether there were
any errors or not on the server side. If the condition is such that you want
to scroll at the top, you can do one of the following:

- Add "#" to the address of the response. For example, if your page is
errors.aspx, the address would be "http://.../errors.aspx#". This will cause
the scroll to top.

- Second option would be to createa hidden field where you specify 'True' or
'False' for example on whether you should scroll or not. Then, in java script
on the client side, you can check for the value of that hidden field to
determine whether you want to scroll or not.

I hope that helps.
-Viksi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top