473,388 Members | 1,286 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Trim Each textbox control

HI

I'm trying to iterate through all the textboxes on a webpage and trim
them for spaces.

i.e. If a user enters " hello world " we correct it to "hello
world"

So far I've come up with this:

-------------------------------------------------------------------------------

'Trim all textboxes
Dim ThisControl As System.Web.UI.Control
For Each ThisControl In Me.Controls

If ThisControl.GetType().ToString() =
"system.Web.UI.WebControls.TextBox" Then

ThisControl.text = Trim(ThisControl.text)
'Above line is wrong syntax, I want to trim the textbox here, but I'm
stuck! Please help...

End If

Next ThisControl

-------------------------------------------------------------------------------

Can you help?

Many Thanks!

Alex
Nov 18 '05 #1
2 1295
use RTrim() and LTrim().
R for right and L for the left side to remove spaces.

"Alex Shirley" <po******@alexshirley.com> schreef in bericht
news:e9**************************@posting.google.c om...
HI

I'm trying to iterate through all the textboxes on a webpage and trim
them for spaces.

i.e. If a user enters " hello world " we correct it to "hello
world"

So far I've come up with this:

-------------------------------------------------------------------------- -----
'Trim all textboxes
Dim ThisControl As System.Web.UI.Control
For Each ThisControl In Me.Controls

If ThisControl.GetType().ToString() =
"system.Web.UI.WebControls.TextBox" Then

ThisControl.text = Trim(ThisControl.text)
'Above line is wrong syntax, I want to trim the textbox here, but I'm
stuck! Please help...

End If

Next ThisControl

-------------------------------------------------------------------------- -----
Can you help?

Many Thanks!

Alex

Nov 18 '05 #2
Hi Richard

The problem I have is not really with the trim function. It's the fact
that I cannot update the control text value. It won't allow the .text
property at all in this example because "thiscontrol" is not actually
aware that the control assigned to it is actually a textbox. Is there a
way to tell it it's a textbox so I can access this property, or is there
another way around this?

Any answers folks?

Cheers

Alex
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mikael Hellström | last post by:
Hi all, i need to use the trim function trim("str","?") My question are. How do i remove the "return sign" from a string?? Regards Mikael
2
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow...
2
by: Alex Shirley | last post by:
HI I'm trying to iterate through all the textboxes on a webpage and trim them for spaces. i.e. If a user enters " hello world " we correct it to "hello world" So far I've come up with...
3
by: FlyerN87 | last post by:
For some reason this command will not trim the names shown in the fields listed. I'm trying to do this in a text box on a report. I've done this fairly succesfully in other reports but I must...
7
by: I am Sam | last post by:
I have a DataGrid that is passing information to a stored procedure properly but the parameters aren't being casted properly. I was woundering if anyone can tell me how I should properly cast the...
7
by: Woody Splawn | last post by:
It is hard for me to imagine a time when you would not want to have the data in a textbox control trimmed. I am hoping there is some sort of switch that can be set for all text boxes so that when...
8
by: Woody Splawn | last post by:
Could someone give me a suggestion for writing generic code in a validating event for trimming the value of a textbox entry? I thought something like the following might work but it does not. ...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
1
OuTCasT
by: OuTCasT | last post by:
Hi everyone. i need to trim text in a textbox. i populate a textbox which is for example company.mdf Now is need to trim the textbox so that it will show company and not company.mdf
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.