asp.net scrolling

Discussion in 'ASP .Net' started by venky, Feb 2, 2005.

  1. venky

    venky Guest

    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?
     
    venky, Feb 2, 2005
    #1
    1. Advertising

  2. venky

    SA Guest

    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" <> wrote in message
    news:...
    > 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?
    >
     
    SA, Feb 2, 2005
    #2
    1. Advertising

  3. venky

    Mark Rae Guest

    "venky" <> wrote in message
    news:...

    >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.
     
    Mark Rae, Feb 2, 2005
    #3
  4. venky

    Peter Blum Guest

    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:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "venky" <> wrote in message
    news:...
    >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?
    >
     
    Peter Blum, Feb 3, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2NvdXRMZWU=?=

    Re: ASP.NET: Listbox scrolling

    =?Utf-8?B?U2NvdXRMZWU=?=, Sep 16, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    759
    =?Utf-8?B?U2NvdXRMZWU=?=
    Sep 16, 2004
  2. Mad Scientist Jr
    Replies:
    0
    Views:
    5,799
    Mad Scientist Jr
    Jan 13, 2005
  3. Phil Johnson
    Replies:
    4
    Views:
    1,054
    Phil Johnson
    Feb 6, 2008
  4. Anil Abraham

    To perform scrolling on an Asp.net page

    Anil Abraham, Apr 4, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    318
    Alexey Smirnov
    Apr 4, 2008
  5. Paul S
    Replies:
    7
    Views:
    10,821
    silver007
    Jun 2, 2008
Loading...

Share This Page