Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > clearing previous selection on browser's back button click

Reply
Thread Tools

clearing previous selection on browser's back button click

 
 
Rosanne
Guest
Posts: n/a
 
      09-23-2005

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

 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      09-23-2005
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('M ySelectBox').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
>



 
Reply With Quote
 
 
 
 
Vonnie
Guest
Posts: n/a
 
      09-25-2005
Using this in the Page Load event should work

Response.Cache.SetCacheability(HttpCacheability.No Cache)
Response.Cache.SetAllowResponseInBrowserHistory(Fa lse)




"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
>



 
Reply With Quote
 
Rosanne
Guest
Posts: n/a
 
      09-26-2005

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

 
Reply With Quote
 
jain jain is offline
Junior Member
Join Date: Aug 2007
Posts: 1
 
      08-21-2007
did u get any solution for ur problem .If so plz post it. I do need the same.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fire both event button click and textchanged when button is click and text is changed Amy ASP .Net 0 06-01-2006 02:33 PM
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Building Controls 1 05-28-2004 06:23 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Datagrid Control 0 05-25-2004 01:45 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57