PC Review


Reply
Thread Tools Rate Thread

Clear all controls on a web page

 
 
Guest
Posts: n/a
 
      6th Aug 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
 
      6th Aug 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
Rate This Thread
Rate This Thread:

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
VBA to clear controls Accessor Microsoft Access VBA Modules 2 29th Sep 2009 10:53 AM
clear the clear the web page email attachment lines =?Utf-8?B?TUNyaWRlcg==?= Microsoft Excel Misc 0 11th Nov 2007 10:05 PM
How to clear or reset controls on page =?Utf-8?B?Q2hyaXM=?= Microsoft ASP .NET 1 13th May 2005 12:33 PM
Controls.Clear and Controls.Add very slow Shane Microsoft Dot NET Compact Framework 3 23rd Sep 2004 08:27 AM
How do I clear all controls on a page when the database is first opened? Mike Matheny Microsoft Access Form Coding 1 5th Oct 2003 10:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:26 PM.