Welcome to Dream.In.Code
Become an Expert!

Join 150,381 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,237 people online right now. Registration is fast and FREE... Join Now!




Clear All Text box in webform

 
Reply to this topicStart new topic

Clear All Text box in webform, ASP.NET

ajit2mail
7 Feb, 2008 - 03:09 AM
Post #1

New D.I.C Head
*

Joined: 7 Feb, 2008
Posts: 1

Any one can give me some quick way how to clear all textbox in web page
without using
textbox1.text="";
textbox2.text="";

....
...
textboxn.text="";

as many time as we have form.



I have seen equivalent code in window, but it seem not in working in ASP.NET
User is offlineProfile CardPM
+Quote Post

Footsie
RE: Clear All Text Box In Webform
7 Feb, 2008 - 12:48 PM
Post #2

D.I.C Regular
Group Icon

Joined: 20 Sep, 2007
Posts: 308



Thanked: 4 times
Dream Kudos: 50
My Contributions
PsychoCoder posted a snippet that does this. Click this link:
Clear a form

This post has been edited by Footsie: 7 Feb, 2008 - 12:48 PM
User is offlineProfile CardPM
+Quote Post

dilipv
RE: Clear All Text Box In Webform
9 Feb, 2008 - 04:09 AM
Post #3

New D.I.C Head
*

Joined: 9 Feb, 2008
Posts: 9

hi ajit,


At the button click event put the following code.
Button_click

ClearTextBoxes()

In vb.net


CODE

Private sub ClearTextBoxes()
TextBox1.Text=""
TextBox2.Text=""
End Sub




In C#.Net

CODE

ClearTextBoxes()
{
TextBox1.Text=""
TextBox2.Text=""
}


Thank you
Jitesh
.Net Consulting

EDIT: Please use code tags when posting any code, like this code.gif

This post has been edited by PsychoCoder: 9 Feb, 2008 - 05:38 AM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Clear All Text Box In Webform
9 Feb, 2008 - 05:39 AM
Post #4

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
He was actually looking for a way where he didn't have to manually type the name and set them to empty like that. The link to the snippet that was provided to him will do that smile.gif
User is offlineProfile CardPM
+Quote Post

ptman
RE: Clear All Text Box In Webform
8 Apr, 2008 - 02:32 AM
Post #5

New D.I.C Head
*

Joined: 8 Apr, 2008
Posts: 1

QUOTE(dilipv @ 9 Feb, 2008 - 05:09 AM) *

hi ajit,


At the button click event put the following code.
Button_click

ClearTextBoxes()

In vb.net


CODE

Private sub ClearTextBoxes()
TextBox1.Text=""
TextBox2.Text=""
End Sub




In C#.Net

CODE

ClearTextBoxes()
{
TextBox1.Text=""
TextBox2.Text=""
}


Thank you
Jitesh
.Net Consulting

EDIT: Please use code tags when posting any code, like this code.gif



string ctrlName;
TextBox ctrl;

for (int i = 0; i < 12; i++)
{
ctrlName = "Textbox" + i;
ctrl = (TextBox)FindControl(ctrlName);
ctrl.Text = "";
}
User is offlineProfile CardPM
+Quote Post

JasonMcAuley
RE: Clear All Text Box In Webform
10 Apr, 2008 - 06:50 AM
Post #6

D.I.C Head
**

Joined: 10 Apr, 2008
Posts: 135



Thanked: 1 times
My Contributions
QUOTE(ptman @ 8 Apr, 2008 - 03:32 AM) *


string ctrlName;
TextBox ctrl;

for (int i = 0; i < 12; i++)
{
ctrlName = "Textbox" + i;
ctrl = (TextBox)FindControl(ctrlName);
ctrl.Text = "";
}


A good idea in concept; but good coding conventions would tell you not to name your text boxes "Textbox1", "Textbox2", etc.


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 04:10PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month