4 Replies - 2687 Views - Last Post: 12 September 2008 - 08:35 AM Rate Topic: -----

#1 krishna_iil   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-September 08

clearing all input box values

Posted 12 September 2008 - 04:09 AM

hai every one , i am creating a web application in C#.Net
in my form i am using Html textbox (Hthlinputtext) i want to clear all values in the inputtext when i press reset button what i used for clearing is

foreach(Control control in this.Controls)

{

if(control.GetType() == typeof(HtmlInputText))

{

control.value= "";

}

}

it is not working can somebody help me with this

Is This A Good Question/Topic? 0
  • +

Replies To: clearing all input box values

#2 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1536
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: clearing all input box values

Posted 12 September 2008 - 05:30 AM

wouldn't it be this?

control.Text = "";


Was This Post Helpful? 0
  • +
  • -

#3 zakary   User is offline

  • D.I.C Regular
  • member icon

Reputation: 27
  • View blog
  • Posts: 427
  • Joined: 15-February 05

Re: clearing all input box values

Posted 12 September 2008 - 05:42 AM

eclipsed4utoo is correct. I would recommend using string.Empty; It does the same as "" it's just easier to read.

control.Text = string.Empty;


Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1663
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: clearing all input box values

Posted 12 September 2008 - 05:57 AM

Moved to ASP.NET :)

Also, I would do this with Javascript, there's really no need for a trip to the server to clear out some TextBoxes
Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1536
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: clearing all input box values

Posted 12 September 2008 - 08:35 AM

View PostPsychoCoder, on 12 Sep, 2008 - 08:57 AM, said:

Moved to ASP.NET :)

Also, I would do this with Javascript, there's really no need for a trip to the server to clear out some TextBoxes


agreed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1