View Full Version : Clearing Forms in C#
helric
07-31-2004, 09:53 AM
Is there a way to reset all web UI controls through C#? I have a code-behind C# app and I just want a way to clear all the text boxes on the page. Problem is that the page is dynamic so I won't know how many text boxes there are to clear. I was going to build my own collection and walk through that but I got to thinking that there's probably a very simple page.reset or something that I could use.
I basically just want to re-initialize the aspx page and send it back to it's original form.
Rich.
bruce
08-01-2004, 02:34 AM
rich,
i do not think there's method to reset all the controls in a page (I could be wrong though).
[b]quote:Originally posted by helric
Is there a way to reset all web UI controls through C#? I have a code-behind C# app and I just want a way to clear all the text boxes on the page. Problem is that the page is dynamic so I won't know how many text boxes there are to clear. I was going to build my own collection and walk through that but I got to thinking that there's probably a very simple page.reset or something that I could use.
I basically just want to re-initialize the aspx page and send it back to it's original form.
Rich.
</blockquote id="quote"></font id="quote">
helric
08-02-2004, 09:52 AM
So I was able to acheive what I wanted in this case by just redirecting to the same page. Doing so seems to dump all the form info.
<center>Response.Redirect(this.Request.Url.AbsoluteUri);</font id="Courier New"></center>
Kind of a cheesy way to do it but it works.
Rich.
bruce
08-03-2004, 12:54 PM
that will definitely do it but you'll lose all other page view stuff
\[b]quote:Originally posted by helric
So I was able to acheive what I wanted in this case by just redirecting to the same page. Doing so seems to dump all the form info.
<center>Response.Redirect(this.Request.Url.AbsoluteUri);</font id="Courier New"></center>
Kind of a cheesy way to do it but it works.
Rich.
</blockquote id="quote"></font id="quote">
droberts
08-12-2004, 12:14 PM
The Page object gives you access to the Controls collection. Once you have a reference, you can loop through all controls on the page. It doesn't matter that the controls where placed dynamically.
Hope this helps
vBulletin® ©Jelsoft Enterprises Ltd.