Reset Drop Down List

Discussion in 'ASP .Net Web Controls' started by Thom Little, Jul 23, 2004.

  1. Thom Little

    Thom Little Guest

    I have a Drop Down List with names and matching URLs. When I select an item
    the handler issues a redirect to the specified URL. If I hit "back" on the
    new page it takes me back to the page with the Drop Down List and the item I
    selected is displayed in the Drop Down List.

    How can I reset the Drop Down List to show the original value (i.e., item 0)
    instead of the value that I selected?

    --
    -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    --
    Thom Little, Jul 23, 2004
    #1
    1. Advertising

  2. Thom Little

    Chris Moore Guest

    Hi,

    I've tried a few times and I'm having trouble reproducing your problem. Could you provide a snippet of code that you are using to do this? I assume that
    the redirect occurs in DropDownList.SelectedIndexChanged()? Are you adding elements to your list programatically or are they static?

    Chris
    --------------------
    >Reply-To: "Thom Little" <>
    >From: "Thom Little" <>
    >Subject: Reset Drop Down List
    >Date: Fri, 23 Jul 2004 15:12:44 -0400
    >Lines: 14
    >Organization: Thom Little Associates, Ltd.
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
    >Message-ID: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
    >NNTP-Posting-Host: bgrwebrydthomlittle.prexar.com 142.167.74.159
    >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
    >Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:22385
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
    >
    >I have a Drop Down List with names and matching URLs. When I select an item
    >the handler issues a redirect to the specified URL. If I hit "back" on the
    >new page it takes me back to the page with the Drop Down List and the item I
    >selected is displayed in the Drop Down List.
    >
    >How can I reset the Drop Down List to show the original value (i.e., item 0)
    >instead of the value that I selected?
    >
    >--
    >-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    >--
    >
    >
    >
    >
    Chris Moore, Jul 24, 2004
    #2
    1. Advertising

  3. Thom Little

    Thom Little Guest

    Chris:

    The complete handler is ...
    private void ddlWindows_SelectedIndexChanged(object sender,
    System.EventArgs e )
    {
    Response.Redirect( ddlWindows.SelectedItem.Value );
    }

    The members are static.
    I use AutoPostBack

    --
    -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    --

    "Chris Moore" <> wrote in message
    news:...
    > Hi,
    >
    > I've tried a few times and I'm having trouble reproducing your problem.

    Could you provide a snippet of code that you are using to do this? I assume
    that
    > the redirect occurs in DropDownList.SelectedIndexChanged()? Are you

    adding elements to your list programatically or are they static?
    >
    > Chris
    > --------------------
    > >Reply-To: "Thom Little" <>
    > >From: "Thom Little" <>
    > >Subject: Reset Drop Down List
    > >Date: Fri, 23 Jul 2004 15:12:44 -0400
    > >Lines: 14
    > >Organization: Thom Little Associates, Ltd.
    > >X-Priority: 3
    > >X-MSMail-Priority: Normal
    > >X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
    > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
    > >Message-ID: <>
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
    > >NNTP-Posting-Host: bgrwebrydthomlittle.prexar.com 142.167.74.159
    > >Path:

    cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
    ..phx.gbl
    > >Xref: cpmsftngxa06.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webcontrols:22385
    > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
    > >
    > >I have a Drop Down List with names and matching URLs. When I select an

    item
    > >the handler issues a redirect to the specified URL. If I hit "back" on

    the
    > >new page it takes me back to the page with the Drop Down List and the

    item I
    > >selected is displayed in the Drop Down List.
    > >
    > >How can I reset the Drop Down List to show the original value (i.e., item

    0)
    > >instead of the value that I selected?
    > >
    > >--
    > >-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    > >--
    > >
    > >
    > >
    > >

    >
    >
    Thom Little, Jul 24, 2004
    #3
  4. Thom Little

    Dale Guest

    Response.Cache.SetCacheability(HttpCacheability.NoCache);

    Dale Preston
    MCAD, MCSE, MCDBA

    "Thom Little" <> wrote in message
    news:...
    > I have a Drop Down List with names and matching URLs. When I select an

    item
    > the handler issues a redirect to the specified URL. If I hit "back" on

    the
    > new page it takes me back to the page with the Drop Down List and the item

    I
    > selected is displayed in the Drop Down List.
    >
    > How can I reset the Drop Down List to show the original value (i.e., item

    0)
    > instead of the value that I selected?
    >
    > --
    > -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    > --
    >
    >
    >
    Dale, Jul 24, 2004
    #4
  5. Thom Little

    Thom Little Guest

    Dale:

    Placing it in Page_Load created the exact behavior that I wanted.

    Thanks for the help.

    --
    -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    --

    "Dale" <> wrote in message
    news:...
    > Response.Cache.SetCacheability(HttpCacheability.NoCache);
    >
    > Dale Preston
    > MCAD, MCSE, MCDBA
    >
    > "Thom Little" <> wrote in message
    > news:...
    > > I have a Drop Down List with names and matching URLs. When I select an

    > item
    > > the handler issues a redirect to the specified URL. If I hit "back" on

    > the
    > > new page it takes me back to the page with the Drop Down List and the

    item
    > I
    > > selected is displayed in the Drop Down List.
    > >
    > > How can I reset the Drop Down List to show the original value (i.e.,

    item
    > 0)
    > > instead of the value that I selected?
    > >
    > > --
    > > -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    > > --
    > >
    > >
    > >

    >
    >
    Thom Little, Jul 24, 2004
    #5
  6. Thom Little

    Thom Little Guest

    Dale:

    Clarification.

    Your approach works perfectly if you are using Internet Explorer as your
    browser.

    Your approach does not work with Firefox, Mozillla, Netscape, or Opera.

    --
    -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    --

    "Dale" <> wrote in message
    news:...
    > Response.Cache.SetCacheability(HttpCacheability.NoCache);
    >
    > Dale Preston
    > MCAD, MCSE, MCDBA
    >
    > "Thom Little" <> wrote in message
    > news:...
    > > I have a Drop Down List with names and matching URLs. When I select an

    > item
    > > the handler issues a redirect to the specified URL. If I hit "back" on

    > the
    > > new page it takes me back to the page with the Drop Down List and the

    item
    > I
    > > selected is displayed in the Drop Down List.
    > >
    > > How can I reset the Drop Down List to show the original value (i.e.,

    item
    > 0)
    > > instead of the value that I selected?
    > >
    > > --
    > > -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    > > --
    > >
    > >
    > >

    >
    >
    Thom Little, Jul 30, 2004
    #6
  7. Thom Little

    Chris Moore Guest

    I tried the code that you have me and there wasn't any problem. But I just noticed from a previous post that your problem is with non-IE browsers. It could
    be that this is a "feature" of Foxfire, Mozilla, etc. and there isn't an elegant way to deal with it. I will try to find some information about these browsers and
    pass it on if I do. Sorry I couldn't be of more help.

    Chris
    --------------------
    >Reply-To: "Thom Little" <>
    >From: "Thom Little" <>
    >References: <> <>
    >Subject: Re: Reset Drop Down List
    >Date: Fri, 23 Jul 2004 20:21:25 -0400
    >Lines: 71
    >Organization: Thom Little Associates, Ltd.
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
    >Message-ID: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
    >NNTP-Posting-Host: bgrwebrydthomlittle.prexar.com 142.167.74.159
    >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
    >Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:22392
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
    >
    >Chris:
    >
    >The complete handler is ...
    > private void ddlWindows_SelectedIndexChanged(object sender,
    >System.EventArgs e )
    > {
    > Response.Redirect( ddlWindows.SelectedItem.Value );
    > }
    >
    >The members are static.
    >I use AutoPostBack
    >
    >--
    >-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    >--
    >
    >"Chris Moore" <> wrote in message
    >news:...
    >> Hi,
    >>
    >> I've tried a few times and I'm having trouble reproducing your problem.

    >Could you provide a snippet of code that you are using to do this? I assume
    >that
    >> the redirect occurs in DropDownList.SelectedIndexChanged()? Are you

    >adding elements to your list programatically or are they static?
    >>
    >> Chris
    >> --------------------
    >> >Reply-To: "Thom Little" <>
    >> >From: "Thom Little" <>
    >> >Subject: Reset Drop Down List
    >> >Date: Fri, 23 Jul 2004 15:12:44 -0400
    >> >Lines: 14
    >> >Organization: Thom Little Associates, Ltd.
    >> >X-Priority: 3
    >> >X-MSMail-Priority: Normal
    >> >X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
    >> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
    >> >Message-ID: <>
    >> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
    >> >NNTP-Posting-Host: bgrwebrydthomlittle.prexar.com 142.167.74.159
    >> >Path:

    >cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
    >.phx.gbl
    >> >Xref: cpmsftngxa06.phx.gbl

    >microsoft.public.dotnet.framework.aspnet.webcontrols:22385
    >> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
    >> >
    >> >I have a Drop Down List with names and matching URLs. When I select an

    >item
    >> >the handler issues a redirect to the specified URL. If I hit "back" on

    >the
    >> >new page it takes me back to the page with the Drop Down List and the

    >item I
    >> >selected is displayed in the Drop Down List.
    >> >
    >> >How can I reset the Drop Down List to show the original value (i.e., item

    >0)
    >> >instead of the value that I selected?
    >> >
    >> >--
    >> >-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    >> >--
    >> >
    >> >
    >> >
    >> >

    >>
    >>

    >
    >
    >
    Chris Moore, Aug 7, 2004
    #7
  8. Thom Little

    Thom Little Guest

    Chris:

    Thank you for the help.

    I have almost come to the conclusion that it needs to be done with a script
    on the client and not code on the server. There is no way I can find to
    reset the index AND do the redirect. It seems to be one or the other.

    One possibility is to set a hidden field with the value on the reset pass
    and then use that value for the redirect. The problem with that is how to
    trigger the second transmission back to the server with the hidden data to
    be used in the redirect.

    The disable cache approach only seems to work on Internet Explorer.

    The page I am playing with is my personal sandbox. It is at
    www.tlacsharp.net/thomlittle

    --
    -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    --

    "Chris Moore" <> wrote in message
    news:...
    > I tried the code that you have me and there wasn't any problem. But I

    just noticed from a previous post that your problem is with non-IE browsers.
    It could
    > be that this is a "feature" of Foxfire, Mozilla, etc. and there isn't an

    elegant way to deal with it. I will try to find some information about
    these browsers and
    > pass it on if I do. Sorry I couldn't be of more help.
    >
    > Chris
    > --------------------
    > >Reply-To: "Thom Little" <>
    > >From: "Thom Little" <>
    > >References: <>

    <>
    > >Subject: Re: Reset Drop Down List
    > >Date: Fri, 23 Jul 2004 20:21:25 -0400
    > >Lines: 71
    > >Organization: Thom Little Associates, Ltd.
    > >X-Priority: 3
    > >X-MSMail-Priority: Normal
    > >X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
    > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
    > >Message-ID: <>
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
    > >NNTP-Posting-Host: bgrwebrydthomlittle.prexar.com 142.167.74.159
    > >Path:

    cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
    ..phx.gbl
    > >Xref: cpmsftngxa06.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webcontrols:22392
    > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
    > >
    > >Chris:
    > >
    > >The complete handler is ...
    > > private void ddlWindows_SelectedIndexChanged(object sender,
    > >System.EventArgs e )
    > > {
    > > Response.Redirect( ddlWindows.SelectedItem.Value );
    > > }
    > >
    > >The members are static.
    > >I use AutoPostBack
    > >
    > >--
    > >-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    > >--
    > >
    > >"Chris Moore" <> wrote in message
    > >news:...
    > >> Hi,
    > >>
    > >> I've tried a few times and I'm having trouble reproducing your problem.

    > >Could you provide a snippet of code that you are using to do this? I

    assume
    > >that
    > >> the redirect occurs in DropDownList.SelectedIndexChanged()? Are you

    > >adding elements to your list programatically or are they static?
    > >>
    > >> Chris
    > >> --------------------
    > >> >Reply-To: "Thom Little" <>
    > >> >From: "Thom Little" <>
    > >> >Subject: Reset Drop Down List
    > >> >Date: Fri, 23 Jul 2004 15:12:44 -0400
    > >> >Lines: 14
    > >> >Organization: Thom Little Associates, Ltd.
    > >> >X-Priority: 3
    > >> >X-MSMail-Priority: Normal
    > >> >X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
    > >> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
    > >> >Message-ID: <>
    > >> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
    > >> >NNTP-Posting-Host: bgrwebrydthomlittle.prexar.com 142.167.74.159
    > >> >Path:

    >
    >cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP1

    1
    > >.phx.gbl
    > >> >Xref: cpmsftngxa06.phx.gbl

    > >microsoft.public.dotnet.framework.aspnet.webcontrols:22385
    > >> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
    > >> >
    > >> >I have a Drop Down List with names and matching URLs. When I select

    an
    > >item
    > >> >the handler issues a redirect to the specified URL. If I hit "back"

    on
    > >the
    > >> >new page it takes me back to the page with the Drop Down List and the

    > >item I
    > >> >selected is displayed in the Drop Down List.
    > >> >
    > >> >How can I reset the Drop Down List to show the original value (i.e.,

    item
    > >0)
    > >> >instead of the value that I selected?
    > >> >
    > >> >--
    > >> >-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    > >> >--
    > >> >
    > >> >
    > >> >
    > >> >
    > >>
    > >>

    > >
    > >
    > >

    >
    >
    Thom Little, Aug 7, 2004
    #8
    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. SirPoonga
    Replies:
    2
    Views:
    738
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    996
    weiwei
    Jan 5, 2007
  3. msimmons
    Replies:
    0
    Views:
    452
    msimmons
    Jul 16, 2009
  4. Replies:
    5
    Views:
    247
  5. Replies:
    3
    Views:
    271
Loading...

Share This Page