What about Anchors (#) and ASP.NET?

Discussion in 'ASP .Net' started by Lars Netzel, Jul 26, 2004.

  1. Lars Netzel

    Lars Netzel Guest

    Hello!

    I have a LOOOOONG page with a bunch of panels that you can expand and
    stuff.. and as you all know when you click on a servercontrol and get a
    postback, it reloads and you end up at the top of the page ... is there
    anyway to get the postback to add a #anchorname to the Address so I can keep
    my location down in the page??

    Regards
    /Lars
     
    Lars Netzel, Jul 26, 2004
    #1
    1. Advertising

  2. Lars Netzel

    Adam Barker Guest

    One way you can do this is inside your Page_Load event you can register some
    startup javascript along the lines of document.location.hash = "mybookmark1"
    which should navigate you to #mybookmark1 within your page. Register the
    script block after check for IsPostBack() if you want to do this after some
    user input/post back event.


    "Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
    news:...
    > Hello!
    >
    > I have a LOOOOONG page with a bunch of panels that you can expand and
    > stuff.. and as you all know when you click on a servercontrol and get a
    > postback, it reloads and you end up at the top of the page ... is there
    > anyway to get the postback to add a #anchorname to the Address so I can

    keep
    > my location down in the page??
    >
    > Regards
    > /Lars
    >
    >
     
    Adam Barker, Jul 26, 2004
    #2
    1. Advertising

  3. Lars Netzel

    Bobby Ryzhy Guest

    On Mon, 26 Jul 2004 17:01:21 +0200, "Lars Netzel" <[stop_spam]@host.topdomain> wrote:

    >Hello!
    >
    >I have a LOOOOONG page with a bunch of panels that you can expand and
    >stuff.. and as you all know when you click on a servercontrol and get a
    >postback, it reloads and you end up at the top of the page ... is there
    >anyway to get the postback to add a #anchorname to the Address so I can keep
    >my location down in the page??
    >
    >Regards
    >/Lars
    >


    You can try some javascript -

    C#
    if (IsPostBack)
    {
    Page.Controls.Add(new LiteralControl("<script language = \"javascript\">"));
    Page.Controls.Add(new LiteralControl(window.location="abc.aspx#123));
    Page.Controls.Add(new LiteralControl("</script>"));
    }


    Bobby Ryzhy
    bobby @ domain below
    http://weekendtech.net
     
    Bobby Ryzhy, Jul 26, 2004
    #3
  4. Lars Netzel

    Lars Netzel Guest

    Thankx!:) Works Fine!

    I need to add it in every single Event that postbacks of course but I guess
    thats fine!

    /Lars

    "Adam Barker" <msnews*NO+S_PA_M*@q-state.co.uk> skrev i meddelandet
    news:...
    > One way you can do this is inside your Page_Load event you can register

    some
    > startup javascript along the lines of document.location.hash =

    "mybookmark1"
    > which should navigate you to #mybookmark1 within your page. Register the
    > script block after check for IsPostBack() if you want to do this after

    some
    > user input/post back event.
    >
    >
    > "Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
    > news:...
    > > Hello!
    > >
    > > I have a LOOOOONG page with a bunch of panels that you can expand and
    > > stuff.. and as you all know when you click on a servercontrol and get a
    > > postback, it reloads and you end up at the top of the page ... is there
    > > anyway to get the postback to add a #anchorname to the Address so I can

    > keep
    > > my location down in the page??
    > >
    > > Regards
    > > /Lars
    > >
    > >

    >
    >
     
    Lars Netzel, Jul 27, 2004
    #4
  5. Lars Netzel

    Greg Burns Guest

    Have you looked at using SmartNavigation?

    http://msdn.microsoft.com/library/d...fSystemWebUIPageClassSmartNavigationTopic.asp

    Greg

    "Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
    news:%...
    > Thankx!:) Works Fine!
    >
    > I need to add it in every single Event that postbacks of course but I

    guess
    > thats fine!
    >
    > /Lars
    >
    > "Adam Barker" <msnews*NO+S_PA_M*@q-state.co.uk> skrev i meddelandet
    > news:...
    > > One way you can do this is inside your Page_Load event you can register

    > some
    > > startup javascript along the lines of document.location.hash =

    > "mybookmark1"
    > > which should navigate you to #mybookmark1 within your page. Register the
    > > script block after check for IsPostBack() if you want to do this after

    > some
    > > user input/post back event.
    > >
    > >
    > > "Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
    > > news:...
    > > > Hello!
    > > >
    > > > I have a LOOOOONG page with a bunch of panels that you can expand and
    > > > stuff.. and as you all know when you click on a servercontrol and get

    a
    > > > postback, it reloads and you end up at the top of the page ... is

    there
    > > > anyway to get the postback to add a #anchorname to the Address so I

    can
    > > keep
    > > > my location down in the page??
    > > >
    > > > Regards
    > > > /Lars
    > > >
    > > >

    > >
    > >

    >
    >
     
    Greg Burns, Jul 27, 2004
    #5
  6. Inside of your page directives, the aspx page, use the
    SmartNavigation=True directive.

    Example: <%@ Page Language="vb" AutoEventWireup="false"
    Codebehind="yourPage.aspx.vb" Inherits="yourProject.yourPage"
    SmartNavigation="True"%>

    This will do all of the dirty anchor work for you when postback is
    caused by an asp.net control.

    Happy Coding!

    Bobby Ryzhy <> wrote in message news:<>...
    > On Mon, 26 Jul 2004 17:01:21 +0200, "Lars Netzel" <[stop_spam]@host.topdomain> wrote:
    >
    > >Hello!
    > >
    > >I have a LOOOOONG page with a bunch of panels that you can expand and
    > >stuff.. and as you all know when you click on a servercontrol and get a
    > >postback, it reloads and you end up at the top of the page ... is there
    > >anyway to get the postback to add a #anchorname to the Address so I can keep
    > >my location down in the page??
    > >
    > >Regards
    > >/Lars
    > >

    >
    > You can try some javascript -
    >
    > C#
    > if (IsPostBack)
    > {
    > Page.Controls.Add(new LiteralControl("<script language = \"javascript\">"));
    > Page.Controls.Add(new LiteralControl(window.location="abc.aspx#123));
    > Page.Controls.Add(new LiteralControl("</script>"));
    > }
    >
    >
    > Bobby Ryzhy
    > bobby @ domain below
    > http://weekendtech.net
     
    Justin Beckwith, Jul 27, 2004
    #6
    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. Chris M

    Bookmark Anchors and VB.NET

    Chris M, Oct 24, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    841
  2. JohnZing

    redirect, parameters and anchors

    JohnZing, Aug 22, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    527
    David Jessee
    Aug 23, 2004
  3. Rowan Malin
    Replies:
    10
    Views:
    1,073
    Foofy (formerly known as Spaghetti)
    May 14, 2004
  4. David Moore

    iframes and anchors

    David Moore, Mar 4, 2006, in forum: HTML
    Replies:
    0
    Views:
    424
    David Moore
    Mar 4, 2006
  5. John Beschler

    Use Anchors in ASP page

    John Beschler, Jul 30, 2003, in forum: ASP General
    Replies:
    4
    Views:
    148
    John Beschler
    Jul 31, 2003
Loading...

Share This Page