Clearing values in WebControls

Discussion in 'ASP .Net' started by John Smith, Jun 28, 2003.

  1. John Smith

    John Smith Guest

    Hi folks,

    I have a form with ASP.NET web controls.
    At the end of the form there's the "Clear" button to clear the available
    values and start over.
    How do I do that?
    The following did not work because it unloaded the controls, and not just
    clearing the values:
    - this.Controls.Clear();

    How do I do it easily? For example, the following pseudo is what I want to
    accomplish:
    - foreach (control in myControlCollection)
    control.ClearValue();
    or the following is just as acceptable since there are only a few control
    type:
    - foreach (control in myControlCollection)
    type = control.GetType()
    switch type
    case 'DropDownList':
    control.Remove.Item();
    case 'TextBox':
    control.Text = "";
    etc. etc.

    What I don't want to do is to have to type in each control instance name and
    reset the values one by one.
    Is this possible?
    If yes, would you please write a small example or point me to a MS:Help
    file/page you found that in.
    Thanks very much.

    - js.
     
    John Smith, Jun 28, 2003
    #1
    1. Advertising

  2. John Smith

    Natty Gur Guest

    John Hi,

    Did you consider using the old (HTML) Reset button?

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Natty Gur, Jun 29, 2003
    #2
    1. Advertising

  3. John Smith

    John Smith Guest

    Doooooh!!!
    Much thanks Nat.
    I feel so silly.

    -js

    "Natty Gur" <> wrote in message news:...
    John Hi,

    Did you consider using the old (HTML) Reset button?

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    John Smith, Jun 29, 2003
    #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. =?Utf-8?B?RHJCeXRlcw==?=

    Webcontrols forgets values and is doing my head in

    =?Utf-8?B?RHJCeXRlcw==?=, Mar 13, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    295
    =?Utf-8?B?RHJCeXRlcw==?=
    Mar 13, 2006
  2. ronnel.santiago

    bind values of dynamically loaded webcontrols to custom object

    ronnel.santiago, Oct 4, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    135
    ronnel.santiago
    Oct 4, 2004
  3. Robin
    Replies:
    2
    Views:
    99
    Alexey V.Zelenin
    Dec 11, 2003
  4. Tyrone Slothrop

    Clearing Field Values

    Tyrone Slothrop, Jun 25, 2005, in forum: Javascript
    Replies:
    6
    Views:
    93
  5. Replies:
    1
    Views:
    81
Loading...

Share This Page