clearing previous selection on browser's back button click

Discussion in 'ASP .Net' started by Rosanne, Sep 23, 2005.

  1. Rosanne

    Rosanne Guest

    Is there a way to clear the SelectedIndex of a listbox when th
    browser's back button is clicked?

    I have a page that contains a server side list box with AutoPostBack
    True. When the user clicks an item in the listbox, they are redirecte
    to an information page based on their selection. On this informatio
    page, if the user clicks the browser's back button they are taken bac
    to the first page with the item in the listbox still highlighted.
    Therefore, if they click anything else on that page that causes a pos
    back, the SelectedIndexChanged event of the listbox is firing agai
    taking them back to the information page. Is there anyway to clear th
    SelectedIndex of this listbox when the browser's back button is clicked


    Thanks in advance!!!

    Rosann

    --
    Rosann
    -----------------------------------------------------------------------
    Rosanne's Profile: http://www.highdots.com/forums/m28
    View this thread: http://www.highdots.com/forums/t294655
     
    Rosanne, Sep 23, 2005
    #1
    1. Advertising

  2. Rosanne,

    How about adding a javascript to the page. If you add it with
    Page.RegisterStartupScript the script will run every first page load. Use
    the script to reset the SelectedIndex.

    Something like this:

    Page.RegisterStartupScript("SelectReset", "<script
    language=""javascript"">document.getElementById('MySelectBox').selectedIndex
    = 0;</script>")

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "Rosanne" <> wrote in message
    news:...
    >
    > Is there a way to clear the SelectedIndex of a listbox when the
    > browser's back button is clicked?
    >
    > I have a page that contains a server side list box with AutoPostBack =
    > True. When the user clicks an item in the listbox, they are redirected
    > to an information page based on their selection. On this information
    > page, if the user clicks the browser's back button they are taken back
    > to the first page with the item in the listbox still highlighted.
    > Therefore, if they click anything else on that page that causes a post
    > back, the SelectedIndexChanged event of the listbox is firing again
    > taking them back to the information page. Is there anyway to clear the
    > SelectedIndex of this listbox when the browser's back button is clicked?
    >
    >
    > Thanks in advance!!!
    >
    > Rosanne
    >
    >
    > --
    > Rosanne
    > ------------------------------------------------------------------------
    > Rosanne's Profile: http://www.highdots.com/forums/m283
    > View this thread: http://www.highdots.com/forums/t2946552
    >
     
    S. Justin Gengo, Sep 23, 2005
    #2
    1. Advertising

  3. Rosanne

    Vonnie Guest

    Using this in the Page Load event should work

    Response.Cache.SetCacheability(HttpCacheability.NoCache)
    Response.Cache.SetAllowResponseInBrowserHistory(False)




    "Rosanne" <> wrote in message
    news:...
    >
    > Is there a way to clear the SelectedIndex of a listbox when the
    > browser's back button is clicked?
    >
    > I have a page that contains a server side list box with AutoPostBack =
    > True. When the user clicks an item in the listbox, they are redirected
    > to an information page based on their selection. On this information
    > page, if the user clicks the browser's back button they are taken back
    > to the first page with the item in the listbox still highlighted.
    > Therefore, if they click anything else on that page that causes a post
    > back, the SelectedIndexChanged event of the listbox is firing again
    > taking them back to the information page. Is there anyway to clear the
    > SelectedIndex of this listbox when the browser's back button is clicked?
    >
    >
    > Thanks in advance!!!
    >
    > Rosanne
    >
    >
    > --
    > Rosanne
    > ------------------------------------------------------------------------
    > Rosanne's Profile: http://www.highdots.com/forums/m283
    > View this thread: http://www.highdots.com/forums/t2946552
    >
     
    Vonnie, Sep 25, 2005
    #3
  4. Rosanne

    Rosanne Guest

    Hi Vonnie -

    Thanks for the suggestion above! I added the 2 lines of code you gav
    me. Now when they click the browser's back button, the page is expire
    and they have to click refresh. Makes sense. And when they clic
    refresh, the item in the list box is no longer selected so it's al
    working correctly. However, I didn't want the page to expire - I onl
    wanted the selection to be cleared. Is there anyway to do that? Th
    users want to be able to use the back button - they will complain abou
    the page expiring and having to refresh. Just wondering if there's
    work around.

    Thanks again for the suggestion! And thanks in advance for an
    thoughts on this issue.

    Rosann

    --
    Rosann
    -----------------------------------------------------------------------
    Rosanne's Profile: http://www.highdots.com/forums/m28
    View this thread: http://www.highdots.com/forums/t294655
     
    Rosanne, Sep 26, 2005
    #4
  5. Rosanne

    jain

    Joined:
    Aug 20, 2007
    Messages:
    1
    jain

    did u get any solution for ur problem .If so plz post it. I do need the same.:sad:
     
    jain, Aug 21, 2007
    #5
    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. Earl Teigrob
    Replies:
    0
    Views:
    581
    Earl Teigrob
    Dec 15, 2003
  2. Quentin Huo
    Replies:
    0
    Views:
    691
    Quentin Huo
    Oct 1, 2004
  3. yasin
    Replies:
    1
    Views:
    615
    Karl Seguin [MVP]
    Apr 20, 2006
  4. Author
    Replies:
    6
    Views:
    3,264
    George
    Jan 22, 2009
  5. Katie
    Replies:
    0
    Views:
    188
    Katie
    Mar 1, 2007
Loading...

Share This Page