persist values from one postback to another

Discussion in 'ASP .Net' started by =?Utf-8?B?Sko=?=, Jun 24, 2005.

  1. Hi,

    Not sure if the title makes sense but heres my dilemma. I have two
    dropdownlist controls on a webform. I want to make sure that the first
    dropdownlist control was clicked on and a value was selected. I want to check
    in the second dropdownlist control that this has happened before processing
    any info. I thought I would set a boolean in the selected event of the first
    ddl control but when the event fires for the second ddl control the boolean
    is set back to false due to the page reloading, I assume. How can I persist
    that boolean value between postbacks? And for this scenario what is the best
    way to achieve my goal if the way im describing is not the best?

    Thanks,

    JJ
    =?Utf-8?B?Sko=?=, Jun 24, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?Sko=?=

    Guest

    Take a look at requiredFieldValidator and custom validator
    , Jun 24, 2005
    #2
    1. Advertising

  3. The easiest way to handle this is to simply check and ensure the first
    control is not set to index 0.

    if(ddlFirstControl.SelectedIndex==0)
    //code to indicate the user did not touch drop down 1
    else
    //code to process dropdown 2

    If you want to persist a boolean (not necessary if the first drop down has
    an invalid value, like "choose one"), you can store it in ViewState.

    //in Drop down change event for the first drop down
    ViewState("FirstControlChanged") = true;


    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    ***************************
    Think Outside the Box!
    ***************************


    "JJ" wrote:

    > Hi,
    >
    > Not sure if the title makes sense but heres my dilemma. I have two
    > dropdownlist controls on a webform. I want to make sure that the first
    > dropdownlist control was clicked on and a value was selected. I want to check
    > in the second dropdownlist control that this has happened before processing
    > any info. I thought I would set a boolean in the selected event of the first
    > ddl control but when the event fires for the second ddl control the boolean
    > is set back to false due to the page reloading, I assume. How can I persist
    > that boolean value between postbacks? And for this scenario what is the best
    > way to achieve my goal if the way im describing is not the best?
    >
    > Thanks,
    >
    > JJ
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN, Jun 24, 2005
    #3
    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. Dave Adler
    Replies:
    3
    Views:
    3,056
    bruce barker
    Feb 18, 2004
  2. Richard Dixson
    Replies:
    1
    Views:
    505
    Joe Fallon
    May 18, 2004
  3. Richard Dixson
    Replies:
    2
    Views:
    729
    Richard Dixson
    May 18, 2004
  4. Grey
    Replies:
    2
    Views:
    609
    Sayed Hashimi
    Sep 7, 2004
  5. =?Utf-8?B?QWlkYXMgUGFzaWxpcw==?=

    Session State doesn't persist after postback (code: C#)

    =?Utf-8?B?QWlkYXMgUGFzaWxpcw==?=, Sep 15, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    6,027
    Bruce Barker
    Sep 15, 2005
Loading...

Share This Page