R
rodchar
hey all,
is there a way to find a textbox id with a search string in the code-behind?
thanks,
rodchar
is there a way to find a textbox id with a search string in the code-behind?
thanks,
rodchar
Nathan Sokalski said: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.