Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Clear all controls on a web page

Reply
Thread Tools

Clear all controls on a web page

 
 
Guest
Posts: n/a
 
      08-06-2008
I'm trying to clear all the textboxes on a webpage, this is the code I use
in an application, but a control doesn't have a text member in a
webform????? I get an error on the "ctl.text" saying there is no text
member. How would I clear all textboxes in a web form.

Private Sub ClearTextboxes

Dim ctl as Control

For each ctl in me.controls

if typeof ctl is textbox

ctl.text = string.empty


End If

Next






 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      08-06-2008
Hi,

here is an example how to loop through controls on the Page:
http://www.aspnet101.com/aspnet101/tips.aspx?id=97

If you want to access Text property, you need to have typed reference (cast
it to TextBox set the value to the property).

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

<tester> wrote in message news:(E-Mail Removed)...
> I'm trying to clear all the textboxes on a webpage, this is the code I use
> in an application, but a control doesn't have a text member in a
> webform????? I get an error on the "ctl.text" saying there is no text
> member. How would I clear all textboxes in a web form.
>
> Private Sub ClearTextboxes
>
> Dim ctl as Control
>
> For each ctl in me.controls
>
> if typeof ctl is textbox
>
> ctl.text = string.empty
>
>
> End If
>
> Next
>
>
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Response.Clear() doesn't clear David ASP .Net 2 01-31-2008 08:32 PM
Using Web.config's <system.web><pages><controls><add /></controls></pages></system.web> To Register UserControls Nathan Sokalski ASP .Net 5 01-10-2007 10:50 AM
Using Web.config's <system.web><pages><controls><add /></controls></pages></system.web> To Register UserControls Nathan Sokalski ASP .Net Web Controls 4 12-21-2006 02:50 AM
Using Web.config's <system.web><pages><controls><add /></controls></pages></system.web> To Register UserControls Nathan Sokalski ASP .Net Building Controls 4 12-21-2006 02:50 AM
How can i do to clear all the textbox using controls? Ricardo Corsi P. Cesar ASP .Net 3 11-21-2003 06:30 PM



Advertisments