Persisting Values

Discussion in 'ASP General' started by James Baker, Jul 9, 2004.

  1. James Baker

    James Baker Guest

    I have a form that has a dropdown list that will cause a post to the same
    page when it's changed. The problem I'm running into is that all of the
    controls reset to their default values (obviously expected behavior).
    What's the recommended/best way to persist these values through the post
    process? I know I could set them to the request.form values of themselves,
    so to speak...but I didn't know if there was a simpler/more efficient way.

    Thanks,
    James
    James Baker, Jul 9, 2004
    #1
    1. Advertising

  2. The only solution that I found was to write the VALUE using
    value=<%response.write request("userName")%>. For the list boxes, I
    chopped of the HTML into two segments such as...

    <%if request("airline") <> "" then%>
    <option value="<%response.write request("airline")%>"<%response.write
    request("airline")</option>
    <%else if%>
    <option value="">---Select Airline---</option>
    <%end if%>
    [rest of the option's here]

    This puts the selected option at the top of the list.

    I STRONGLY recommend avoiding the specifying which options is SELECTED.
    I had mutliple problems with this when I was testing across different
    browsers with and without the a particular option selected. Writing the
    value from the request as the first option achieves the same effect as
    if it were written using SELECTED.

    David H


    James Baker wrote:
    > I have a form that has a dropdown list that will cause a post to the same
    > page when it's changed. The problem I'm running into is that all of the
    > controls reset to their default values (obviously expected behavior).
    > What's the recommended/best way to persist these values through the post
    > process? I know I could set them to the request.form values of themselves,
    > so to speak...but I didn't know if there was a simpler/more efficient way.
    >
    > Thanks,
    > James
    >
    >
    David C. Holley, Jul 9, 2004
    #2
    1. Advertising

  3. James Baker

    James Baker Guest

    Thanks for the reply. Only issue I have with that 'selected' issue is, I
    have a multi-select box. Am I SOL?

    "David C. Holley" <> wrote in message
    news:...
    > The only solution that I found was to write the VALUE using
    > value=<%response.write request("userName")%>. For the list boxes, I
    > chopped of the HTML into two segments such as...
    >
    > <%if request("airline") <> "" then%>
    > <option value="<%response.write request("airline")%>"<%response.write
    > request("airline")</option>
    > <%else if%>
    > <option value="">---Select Airline---</option>
    > <%end if%>
    > [rest of the option's here]
    >
    > This puts the selected option at the top of the list.
    >
    > I STRONGLY recommend avoiding the specifying which options is SELECTED.
    > I had mutliple problems with this when I was testing across different
    > browsers with and without the a particular option selected. Writing the
    > value from the request as the first option achieves the same effect as
    > if it were written using SELECTED.
    >
    > David H
    >
    >
    > James Baker wrote:
    > > I have a form that has a dropdown list that will cause a post to the

    same
    > > page when it's changed. The problem I'm running into is that all of the
    > > controls reset to their default values (obviously expected behavior).
    > > What's the recommended/best way to persist these values through the post
    > > process? I know I could set them to the request.form values of

    themselves,
    > > so to speak...but I didn't know if there was a simpler/more efficient

    way.
    > >
    > > Thanks,
    > > James
    > >
    > >

    >
    James Baker, Jul 9, 2004
    #3
  4. James Baker

    Bullschmidt Guest

    <<
    I have a form that has a dropdown list that will cause a post to the
    same page when it's changed. The problem I'm running into is that all of
    the controls reset to their default values (obviously expected
    behavior).
    What's the recommended/best way to persist these values through the post
    process? I know I could set them to the request.form values of
    themselves, so to speak...but I didn't know if there was a simpler/more
    efficient way.
    >>


    Perhaps this may hopefully give some ideas, it's got a downloadable
    sample, and does retain values after the post back:

    ASP Design Tips - Dependent Listboxes
    http://www.bullschmidt.com/devtip-dependentlistboxes.asp

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Designer
    http://www.Bullschmidt.com
    ASP Designer Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Bullschmidt, Jul 9, 2004
    #4
  5. James Baker

    David Holley Guest

    Well if you're using a multiple-select box, the solution is simple -
    DON'T! (It only hurts when I bend it like this...)

    I'm clueless at that point, since I haven't encountered that problem
    yet.

    David H

    www.gatewayorlando.com

    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    David Holley, Jul 9, 2004
    #5
  6. Hmmmm....but you could try something where you kind of 'fool' your
    visitor. When the page resubmits to itself, if there's an option in the
    list box selected you could write a list box populated ONLY with
    selected values - each with the SELECTED spec in the <option> tag. Then
    provide the user when a CHANGE or CLEAR button that resubmits back to
    the page, but with a querystring value that tells the page to draw the
    list box with ALL possible values.

    EVENT: Initial Page Load
    ACTION: Populate list box with all possible values

    EVENT: Self-submit - no value in the querystring or no values selected
    ACTION: Populate list box with all possible values

    EVENT: Self-submit - no value in the querystring, but values selected
    ACTION: Populate list box with values from the request with each one
    having the SELECT specified
    Show the CHANGE/CLEAR button

    EVENT: Self-submit - value in the querystring
    ACTION: Populate list box with all possible values

    I'm a bit frazzeled from work but at least that might get you going in
    the right direction.

    David H

    James Baker wrote:
    > Thanks for the reply. Only issue I have with that 'selected' issue is, I
    > have a multi-select box. Am I SOL?
    >
    > "David C. Holley" <> wrote in message
    > news:...
    >
    >>The only solution that I found was to write the VALUE using
    >>value=<%response.write request("userName")%>. For the list boxes, I
    >>chopped of the HTML into two segments such as...
    >>
    >><%if request("airline") <> "" then%>
    >><option value="<%response.write request("airline")%>"<%response.write
    >>request("airline")</option>
    >><%else if%>
    >><option value="">---Select Airline---</option>
    >><%end if%>
    >>[rest of the option's here]
    >>
    >>This puts the selected option at the top of the list.
    >>
    >>I STRONGLY recommend avoiding the specifying which options is SELECTED.
    >>I had mutliple problems with this when I was testing across different
    >>browsers with and without the a particular option selected. Writing the
    >>value from the request as the first option achieves the same effect as
    >>if it were written using SELECTED.
    >>
    >>David H
    >>
    >>
    >>James Baker wrote:
    >>
    >>>I have a form that has a dropdown list that will cause a post to the

    >
    > same
    >
    >>>page when it's changed. The problem I'm running into is that all of the
    >>>controls reset to their default values (obviously expected behavior).
    >>>What's the recommended/best way to persist these values through the post
    >>>process? I know I could set them to the request.form values of

    >
    > themselves,
    >
    >>>so to speak...but I didn't know if there was a simpler/more efficient

    >
    > way.
    >
    >>>Thanks,
    >>>James
    >>>
    >>>

    >>

    >
    >
    David C. Holley, Jul 10, 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. John

    Persisting values on a webform

    John, Oct 10, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    383
    Xavier Pacheco
    Oct 10, 2004
  2. Server Control
    Replies:
    4
    Views:
    758
  3. Carlos
    Replies:
    3
    Views:
    5,016
    PeterKellner
    May 17, 2006
  4. Falcolas
    Replies:
    3
    Views:
    236
    Bruno Desthuilliers
    Nov 5, 2007
  5. Replies:
    3
    Views:
    251
    Dennis Lee Bieber
    Nov 21, 2007
Loading...

Share This Page