I like the code it is very helpful in resetting all textboxes. But I have a question, if I have 40 textboxes and I want 38 of them to be reset and I don't want to reset the remaining two textboxes in the form (ex: FirstName and LastName). Using your code resets everything but I want the FirstName and LastName to be omitted from the reset method. How can I do it?
Although nothing new, I like this one and have done similar things in the past. +4. My issue with this is that if there are that many text controls on a page that would warrant this approach to clear them all, then the page is perhaps too large. As well, in my experience, text boxes on a form are usually set to a default state and that default state on a properly designed form would contain values other than string.empty.
Reason for my vote of 3
What is the purpose of Calling ClearInputs(ctrl.controls) again inside of foreach loop. I think the result will be same, when we left this line?
mr.Prabhu_R did u check my code before write this comment? Dont do like this hereafter. Check the code in your IDE afterwards post any comments ok. Your brain doesnt have any debugging tools. got it. remove that line and check if it works or not then u can post a comment got it.
What about the situation where we need to clear some of the textbox and not all.I know your solution is specific for situation where all the text boxes need to be cleared. But i am looking for a situation in which i can clear some of the text box. Can we explicitly build a control collection in which we include only text boxes that we need to clear.
if you want to clear the specific text box means u will write textbox1.text="" only. Ok. each time we will write a code for which textbox we want to be clear.
Check it out here: Click Here for the code. Look at the second set of codes. It will clear all textbox controls except those with a specified name. Its vb but its easy to convert. I think this is what you were wanting?
This is the easiest way in my experience. In web application you can use javascript coding to clear all the text boxes. But in window application this is the way..
Last Visit: 31-Dec-99 18:00 Last Update: 23-Sep-24 7:37