all groups > asp.net > june 2003 >
You're in the

asp.net

group:

Clearing values in WebControls


Clearing values in WebControls John Smith
6/28/2003 7:47:02 PM
asp.net: 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.

Re: Clearing values in WebControls Natty Gur
6/28/2003 9:58:17 PM
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 ***
Re: Clearing values in WebControls John Smith
6/29/2003 8:21:32 PM
Doooooh!!!
Much thanks Nat.
I feel so silly.

-js

[quoted text, click to view]
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 ***
AddThis Social Bookmark Button