Can you jump to an anchor on postback?

Discussion in 'ASP .Net' started by darrel, Feb 8, 2005.

  1. darrel

    darrel Guest

    I have an anchor on my page:

    <a name="monkey"></a>

    I can easily go to this via a redirect, but is there a way to jump to this
    on postback?

    -Darrel
     
    darrel, Feb 8, 2005
    #1
    1. Advertising

  2. Sure. Just add a JavaScript to the page that does the "redirect" -

    <script type="text/javascript"><!--
    document.location = "thispage.aspx#bookmark";
    // --></script>

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.

    "darrel" <> wrote in message
    news:...
    >I have an anchor on my page:
    >
    > <a name="monkey"></a>
    >
    > I can easily go to this via a redirect, but is there a way to jump to this
    > on postback?
    >
    > -Darrel
    >
    >
     
    Kevin Spencer, Feb 8, 2005
    #2
    1. Advertising

  3. darrel

    Ollie Riches Guest

    check out using SmartNavigation for returning to the correct place on a page
    after a post back

    HTH

    Ollie Riches

    "darrel" <> wrote in message
    news:...
    > I have an anchor on my page:
    >
    > <a name="monkey"></a>
    >
    > I can easily go to this via a redirect, but is there a way to jump to this
    > on postback?
    >
    > -Darrel
    >
    >
     
    Ollie Riches, Feb 8, 2005
    #3
  4. darrel

    darrel Guest


    > check out using SmartNavigation for returning to the correct place on a

    page
    > after a post back


    Ha! The first result from google is:

    "Smart navigation is more of a pain than good."

    ;o)

    I'll look into it, though I'm thinking Kevin's answer might be the solution.
    Not a big fan of javascript for this, but since this is on an intranet, it's
    not as big of a deal.

    -Darrel
     
    darrel, Feb 8, 2005
    #4
  5. darrel

    darrel Guest

    > Sure. Just add a JavaScript to the page that does the "redirect" -
    >
    > <script type="text/javascript"><!--
    > document.location = "thispage.aspx#bookmark";
    > // --></script>


    Hmm...does that reload the page or merely jump to the anchor? Would this
    work as well:

    document.location = "#bookmark";?

    -Darrel
     
    darrel, Feb 8, 2005
    #5
  6. darrel

    Ollie Riches Guest

    SmartNavigation is not a pain at all as long as you remember some very
    important folders, make sure that the folders with the prefix '_vti_' are
    included in the root directory of the installed asp.net application
    otherwise you will see funny behaviour with SmartNavigation, by default they
    are installed in \Inetpub\wwwroot automatically so you don't have to worry
    about it if your asp.net application resides under this directory.

    Also it only works in IE I believe, it does work in Firefox (Mozilla).

    HTH

    Ollie Riches


    "darrel" <> wrote in message
    news:...
    >
    > > check out using SmartNavigation for returning to the correct place on a

    > page
    > > after a post back

    >
    > Ha! The first result from google is:
    >
    > "Smart navigation is more of a pain than good."
    >
    > ;o)
    >
    > I'll look into it, though I'm thinking Kevin's answer might be the

    solution.
    > Not a big fan of javascript for this, but since this is on an intranet,

    it's
    > not as big of a deal.
    >
    > -Darrel
    >
    >
     
    Ollie Riches, Feb 8, 2005
    #6
  7. Sure. Six of one of half of one of half of a dozen of the other.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.

    "darrel" <> wrote in message
    news:...
    >> Sure. Just add a JavaScript to the page that does the "redirect" -
    >>
    >> <script type="text/javascript"><!--
    >> document.location = "thispage.aspx#bookmark";
    >> // --></script>

    >
    > Hmm...does that reload the page or merely jump to the anchor? Would this
    > work as well:
    >
    > document.location = "#bookmark";?
    >
    > -Darrel
    >
    >
     
    Kevin Spencer, Feb 8, 2005
    #7
  8. > Not a big fan of javascript for this, but since this is on an intranet,
    > it's


    If you're not a big fan of JavaScript, you might as well forget about
    ASP.Net, which relies heavily upon JavaScript for much of its functionality
    (ViewState, PostBacks, etc)!

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.

    "darrel" <> wrote in message
    news:...
    >
    >> check out using SmartNavigation for returning to the correct place on a

    > page
    >> after a post back

    >
    > Ha! The first result from google is:
    >
    > "Smart navigation is more of a pain than good."
    >
    > ;o)
    >
    > I'll look into it, though I'm thinking Kevin's answer might be the
    > solution.
    > Not a big fan of javascript for this, but since this is on an intranet,
    > it's
    > not as big of a deal.
    >
    > -Darrel
    >
    >
     
    Kevin Spencer, Feb 8, 2005
    #8
  9. darrel

    darrel Guest


    > Also it only works in IE I believe


    Hmm...well, there's my reason not to use it, I guess.

    -Darrel
     
    darrel, Feb 8, 2005
    #9
  10. darrel

    darrel Guest


    > If you're not a big fan of JavaScript, you might as well forget about
    > ASP.Net, which relies heavily upon JavaScript for much of its

    functionality
    > (ViewState, PostBacks, etc)!


    It's ridiculous, IMHO. I end up having to simply write a lot of workarounds
    for it.

    A server side language should not be dependant on client-side scripting, but
    MS, as usual, took the easy way out on a lot of the built-in control
    behaviors.

    They're actually great to whip up quick interfaces on intranets where you
    can control the client-side environment to an extent, but useless on the
    greater web if accessibility is a concern.

    IMHO, of course.

    -Darrel
     
    darrel, Feb 8, 2005
    #10
  11. darrel

    Matt Berther Guest

    Hello darrel,

    > A server side language should not be dependant on client-side
    > scripting, but MS, as usual, took the easy way out on a lot of the
    > built-in control behaviors.


    Please do tell how you except a web application not be dependent on client
    side scripting. Also, Im interested to hear in how Microsoft "as usual, took
    the easy way out".

    This is not a fault of Microsoft, but rather the very nature of HTML.

    --
    Matt Berther
    http://www.mattberther.com
     
    Matt Berther, Feb 8, 2005
    #11
  12. darrel

    darrel Guest

    > Please do tell how you except a web application not be dependent on client
    > side scripting.


    We've been doing it that way for years.

    > Also, Im interested to hear in how Microsoft "as usual, took
    > the easy way out"
    > This is not a fault of Microsoft, but rather the very nature of HTML.


    Many of the built in controls require javascript. They could have built the
    workarounds themselves...just like I am doing. Is it as elegant? No. But
    it's accessible.

    As for being lazy...look at client-side form validation and the Ollie's
    comment on smart navigation both being dependant on IE. That's laziness.
    Take the fact that a datalist using columns and an odd-number dataset can't
    generate a compliant table without workarounds. That's laziness. Take the
    fact that datagrids and other table-based controls don't give you default
    options for table headers and such. Laziness. The fact that VS.net still
    messes with my HTML...a known bug by MS that they just don't want to fix.
    Laziness.

    And MS isn't alone in this...seems to be defacto for software development
    these days. ;o)

    -Darrel
     
    darrel, Feb 8, 2005
    #12
  13. darrel

    darrel Guest

    > This is not a fault of Microsoft, but rather the very nature of HTML.

    FYI, HTML is what it is. The web protocols are what they are. It's a
    stateless environment. MS chose to work around this with viewstates and
    postbacks and depending on client-side scripting. There simply is a tradeoff
    here.

    I think it's great for controlled environment application development. I
    think the tradoffs start to show when developing public-facing web sites
    where accessibility is a priority.

    -Darrel
     
    darrel, Feb 8, 2005
    #13
  14. One man's laziness is another man's productivity.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.

    "darrel" <> wrote in message
    news:...
    >> Please do tell how you except a web application not be dependent on
    >> client
    >> side scripting.

    >
    > We've been doing it that way for years.
    >
    >> Also, Im interested to hear in how Microsoft "as usual, took
    >> the easy way out"
    >> This is not a fault of Microsoft, but rather the very nature of HTML.

    >
    > Many of the built in controls require javascript. They could have built
    > the
    > workarounds themselves...just like I am doing. Is it as elegant? No. But
    > it's accessible.
    >
    > As for being lazy...look at client-side form validation and the Ollie's
    > comment on smart navigation both being dependant on IE. That's laziness.
    > Take the fact that a datalist using columns and an odd-number dataset
    > can't
    > generate a compliant table without workarounds. That's laziness. Take the
    > fact that datagrids and other table-based controls don't give you default
    > options for table headers and such. Laziness. The fact that VS.net still
    > messes with my HTML...a known bug by MS that they just don't want to fix.
    > Laziness.
    >
    > And MS isn't alone in this...seems to be defacto for software development
    > these days. ;o)
    >
    > -Darrel
    >
    >
     
    Kevin Spencer, Feb 8, 2005
    #14
  15. darrel

    darrel Guest

    > One man's laziness is another man's productivity.

    :eek:)

    -Darrel
     
    darrel, Feb 8, 2005
    #15
  16. darrel

    Matt Berther Guest

    Hello darrel,

    > Many of the built in controls require javascript. They could have
    > built the workarounds themselves...just like I am doing. Is it as
    > elegant? No. But it's accessible.


    Would you mind describing the workarounds you're talking about?

    > As for being lazy...look at client-side form validation and the
    > Ollie's comment on smart navigation both being dependant on IE. That's
    > laziness. Take the fact that a datalist using columns and an
    > odd-number dataset can't generate a compliant table without
    > workarounds. That's laziness. Take the fact that datagrids and other
    > table-based controls don't give you default options for table headers


    I'll give you those. The controls arent perfect, but your statement was pretty
    broad.

    > and such. Laziness. The fact that VS.net still messes with my HTML...a
    > known bug by MS that they just don't want to fix. Laziness.


    This has been resolved in VS.NET 2005.

    >
    > And MS isn't alone in this...seems to be defacto for software
    > development these days. ;o)


    Without question, you're right there. There has been a definite propensity
    by software developers to just hack and bang stuff together and hope that
    it works. No regard to proper OO design. If it works, its right. And thats
    too bad.

    --
    Matt Berther
    http://www.mattberther.com
     
    Matt Berther, Feb 8, 2005
    #16
  17. darrel

    darrel Guest

    > > Many of the built in controls require javascript. They could have
    > > built the workarounds themselves...just like I am doing. Is it as
    > > elegant? No. But it's accessible.

    >
    > Would you mind describing the workarounds you're talking about?


    Well, the workaround, for me at least, is to depend on lots of querystrings
    with redirect and/or setting viewstate properties in the codebehind. I just
    can't accept postbacks triggered via javascript on the public site I'm
    working on.

    -Darrel
     
    darrel, Feb 8, 2005
    #17
    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. Robert Wehofer

    How to jump to an anchor?

    Robert Wehofer, Nov 13, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    3,250
    John Carnahan
    Nov 17, 2003
  2. Aaron Freeman
    Replies:
    7
    Views:
    1,762
    Jonathan N. Little
    Mar 17, 2006
  3. Robert Mark Bram

    Jump to named anchor after form processing

    Robert Mark Bram, Oct 20, 2004, in forum: ASP General
    Replies:
    3
    Views:
    201
    Evertjan.
    Oct 21, 2004
  4. TWW
    Replies:
    1
    Views:
    144
    A. Sinan Unur
    Jul 16, 2003
  5. Eadwine Rose
    Replies:
    2
    Views:
    221
    Eadwine Rose
    Oct 15, 2006
Loading...

Share This Page