473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

asp.net scrolling

I have a question. In asp.net page, how do u scroll to particular
position in a page. I have a button at the end of my page, when i click
the button, i do some validation and if the validation fails, i want to
scroll to particular postition in the page. Instead the page stays in
the same place where the button is.
any idea or inputs on scrolling?

Nov 19 '05 #1
3 7407
SA
Because scrolling is a client-side function, you will need to implement this
client-side using a combination of JavaScript and anchor tags.

Then, you will need to figure out which control didn't pass the validation
and call your JavaScript function with a parameter that will position the
page at the right place.

This is a brief, untested example

<script language="JavaScript">
function navToLocal(anchorName)
{
// JavaScript code here to navigate to the anchor tag with the
specified name.
}
</script>

<a name="SomeName"></a><asp:TextBox runat="server"...></asp:TextBox>

<script language="vb" runat="server">
' Find out which control didn't validate and which anchor tag
' that control corresponds to.
' On page load, set an onload attribute on the body that will
' correctly call the navToLocal function.
</script>
Can't write most of the code of the top of my head, but I am sure Google
search will reveal most of what you need.

HTH
--

---

Sven.

"venky" <ve************@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I have a question. In asp.net page, how do u scroll to particular
position in a page. I have a button at the end of my page, when i click
the button, i do some validation and if the validation fails, i want to
scroll to particular postition in the page. Instead the page stays in
the same place where the button is.
any idea or inputs on scrolling?

Nov 19 '05 #2
"venky" <ve************@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I have a question. In asp.net page, how do u scroll to particular
position in a page. I have a button at the end of my page, when i click
the button, i do some validation and if the validation fails, i want to
scroll to particular postition in the page. Instead the page stays in
the same place where the button is.


Is your intended goal simply to show the user where the validation has
failed? In which case, I would *strongly* suggest you set focus to the field
which has failed validation by using the JavaScript focus() method. If the
field is currently off the edge of the screen, this will cause the page to
scroll automatically for you so that the field is visible.
Nov 19 '05 #3
Microsoft's validation controls are not really designed for client-side
expandability. For example, if you took the suggestion of setting focus to a
field with the error, how would you write code that finds the first field
with the error and connect it up to Microsoft's scripts that fire when the
button is pressed. You will do some creative hacking to figure it out.

I want to let you know about an alternative that solves this. I rewrite
ASP.NET validation in "Professional Validation And More"
(http://www.peterblum.com/vam/home.aspx). It has 22 validators, support for
validation groups, and support for many more browsers in client-side
validation, like Mozilla, Opera 7 and Safari.

I listened to developers who were asking for many enhancements to ASP.NET
and addressed their needs. In your case, you will find these features:
1. There is an option to have it set focus to the first field with the error
upon submit or after you change a field. It can also change the style of
fields with errors, blink the error message, and put up an alert.
2. My ValidationSummary control can offer hyperlinks on its error messages.
When you click on a hyperlink, it jumps to the field with that error.
3. My ValidationSummary control has a setting that makes the page scroll to
show it when you click submit.

I include a utility to quickly switch a page from Microsoft's to my
validators.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"venky" <ve************@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I have a question. In asp.net page, how do u scroll to particular
position in a page. I have a button at the end of my page, when i click
the button, i do some validation and if the validation fails, i want to
scroll to particular postition in the page. Instead the page stays in
the same place where the button is.
any idea or inputs on scrolling?

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Midas NDT Sales | last post by:
I have been looking at a simple example of a scrolling text box (the one in the SAM book) as below: <script language="JavaScript"> var pos=100; function Scroll() { if...
1
by: Kirk | last post by:
Is it possible to stop horizontal scrolling whilst still maintaining vertical scrolling within an <IFRAME> ? Within each page of my site I have an IFRAME for content. For some pages there is...
44
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
1
by: Tim Frawley | last post by:
I have a large form with many controls, almost like legal size paper in height. Just so I can head these off, I am not looking for suggestions to the effect of using Tab controls, multi-window...
2
by: P2P | last post by:
Hi I am wondering if someone know of a free cross-browsers vertical scrolling script that - is cross cross-browsers - will call the scrolling content from an external html page or from a...
4
by: Keith Bentrup | last post by:
Hi all, I wrote a simple search function to find text in a textarea where not all the text is visible (ie. the text box displays 10 lines but there may be more than 1000 lines to search). I can...
1
by: atif | last post by:
Hi, I m new to CSharp.. so may be my preliminary questions look stupid.. but plz help me.. I want to drag controls like buttons or some other user controls over form.. i have set form's...
5
by: PythonistL | last post by:
I am a newbie with Javascript. I have this simple script for scrolling text <HTML> <HEAD> <TITLE>Scrolling Message Script</TITLE> <SCRIPT language="JavaScript"><!-- var msg = 'My scrolling...
3
by: Chamnap | last post by:
Hello everybody, I have one problem. I want to do something after the user finished scrolling. The scroll event fires whenever the user is scrolling. I don't want this actually. Does anyone has...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.