ASP.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a ASP.NET Expert!

Join 300,406 ASP.NET Programmers for FREE! Get instant access to thousands of ASP.NET experts, tutorials, code snippets, and more! There are 1,622 people online right now. Registration is fast and FREE... Join Now!




Clear All Text box in webform

 

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



Thanked: 1 times
My Contributions
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: 337



Thanked: 8 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

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,714



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

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: 144



Thanked: 3 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

shailendra110580

RE: Clear All Text Box In Webform

1 Jul, 2009 - 03:01 AM
Post #7

New D.I.C Head
*

Joined: 1 Jul, 2009
Posts: 1

QUOTE(ajit2mail @ 7 Feb, 2008 - 03:09 AM) *

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


javascript funtion
function textClearAndNormal()
{

document.getElementById("Text1").value="";document.getElementById("Text1").style.fontStyle= "normal";
}

and in aspx page
text box property set as
onclick="textClearAndNormal()"
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 10:48PM

Live ASP.NET Help!

Be Social

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

ASP.NET Tutorials

Reference Sheets

ASP.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month