473,405 Members | 2,354 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,405 software developers and data experts.

finding a textbox with a search string

hey all,
is there a way to find a textbox id with a search string in the code-behind?
thanks,
rodchar
Jul 10 '08 #1
4 1282
What exactly do you mean by "find a textbox id"? Is there a Textbox that you
know something about that you do not know the id of? If you could please
clarify your question, I may be able to help you better.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:2F**********************************@microsof t.com...
hey all,
is there a way to find a textbox id with a search string in the
code-behind?
thanks,
rodchar

Jul 10 '08 #2
my controls are dynamically generated and i won't know what the id is until
runtime and i'd like to know what the first textbox id is so i can set focus
to it.

"Nathan Sokalski" wrote:
What exactly do you mean by "find a textbox id"? Is there a Textbox that you
know something about that you do not know the id of? If you could please
clarify your question, I may be able to help you better.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:2F**********************************@microsof t.com...
hey all,
is there a way to find a textbox id with a search string in the
code-behind?
thanks,
rodchar


Jul 10 '08 #3
I don't believe a control has an ID you can use in the codebehind if you
don't assign a value to the ID property (I believe one is generated during
runtime, but this may not always be the same, so it is best to not try and
use it). Here are two possibilities you can try:

1. When generating the TextBoxes, set the ID property.

2. Enumerate through the Controls collection. As you look at each control,
check to see if it is a TextBox. I have not seen your entire code, and
sometimes using this technique is inefficient depending on what and how many
controls you have, so this may not always be the best choice.

I would suggest using #1, because it is simple and usually efficient. As far
as what value you should use as the ID, you can generate a String (probably
using the String.Format() method). Hopefully this helps.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:EE**********************************@microsof t.com...
my controls are dynamically generated and i won't know what the id is
until
runtime and i'd like to know what the first textbox id is so i can set
focus
to it.

"Nathan Sokalski" wrote:
>What exactly do you mean by "find a textbox id"? Is there a Textbox that
you
know something about that you do not know the id of? If you could please
clarify your question, I may be able to help you better.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:2F**********************************@microso ft.com...
hey all,
is there a way to find a textbox id with a search string in the
code-behind?
thanks,
rodchar



Jul 10 '08 #4
thanks for the help,
rod.

"Nathan Sokalski" wrote:
I don't believe a control has an ID you can use in the codebehind if you
don't assign a value to the ID property (I believe one is generated during
runtime, but this may not always be the same, so it is best to not try and
use it). Here are two possibilities you can try:

1. When generating the TextBoxes, set the ID property.

2. Enumerate through the Controls collection. As you look at each control,
check to see if it is a TextBox. I have not seen your entire code, and
sometimes using this technique is inefficient depending on what and how many
controls you have, so this may not always be the best choice.

I would suggest using #1, because it is simple and usually efficient. As far
as what value you should use as the ID, you can generate a String (probably
using the String.Format() method). Hopefully this helps.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:EE**********************************@microsof t.com...
my controls are dynamically generated and i won't know what the id is
until
runtime and i'd like to know what the first textbox id is so i can set
focus
to it.

"Nathan Sokalski" wrote:
What exactly do you mean by "find a textbox id"? Is there a Textbox that
you
know something about that you do not know the id of? If you could please
clarify your question, I may be able to help you better.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:2F**********************************@microsof t.com...
hey all,
is there a way to find a textbox id with a search string in the
code-behind?
thanks,
rodchar


Aug 4 '08 #5

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

Similar topics

1
by: Tristan | last post by:
Im trying to expand a search util by uing regular expression to allow common search criteria such as +-* and phrases "". My understanding of ereg(string pattern, string string, ) is that the...
2
by: jason | last post by:
Hello. I've got this js function I call from an html input button. It finds the occurance of a string in a textbox, selects it and scrolls into view. JS newbie question, considering it's a...
1
by: JS | last post by:
I have a textbox and a button. Sometimes this textbox will be disabled and other times it will be enabled. When its disabled I guess its value is null. But is the the text string "null" or is it...
7
by: Tamir Khason | last post by:
I have textbox. I do something in each Keypress (kindof validation) in order not to rewrite all text inside I'm using AppendText method to write in. BUT I'm unable to add backspace (\b); e.g I have...
3
by: Simon Harvey | last post by:
Hi All. In one of my user controls I add a textbox to a placeholder sitting on the user control. txtUsername = new TextBox(); txtUsername.ID = "txtUsername";...
11
by: Joe | last post by:
Hello All, I have an ASP.NET page with one Textbox (SearchTextBox) and one ImageButton (SearchButton) server controls. The user can type search text in SearchTextBox and click SearchButton and...
2
by: Materialised | last post by:
Hi All, I have a problem. I have multiple text boxes on one form. When the user clicks in any of these text boxes, another (search) form opens which queries a database and returns the search...
1
by: Chris Lincoln | last post by:
Hello, I can't quite seem to figure out this issue; it is specific to Firefox, as it works fine in IE. I have an iFrame within an aspx page that is passed a value in the query string (e.g....
9
by: weirdguy | last post by:
Hello, Just for anyone information, there is a similar title "Search in Listbox" but it is via Combo Box. In case, anyone need it, I put a link to here. Please let me know if I break any rules...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.