473,386 Members | 1,973 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,386 software developers and data experts.

FindControl Question

Ok, thanks to a kind person yesterday, I've started using the FindControl()
method. Although I able to get this to work for Web Controls, I'm unable to
find the HTML Controls? Am I missing something still? Do I really have to
use the Web controls in order to be able to change properties on the
control?

I'm trying to create a user control and have the apsx page include that
control, but change a few properties, like the Table Border size, or the
HTMLInputText.Name on a text field. Possible? FindControl() doesn't seem
to work unless it's a Web control... Am I missing something?

Thanks in advance!
Andrea
Nov 18 '05 #1
3 1375
Just to make sure, is the HTML web control associated with runat="server"
i.e it is server-side control? For example: <input type="hidden"
ID="theHidden" runat="server" />

I am asking because FindControl can only locate controls with runat="server"
i.e server-side controls.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Andrea Williams" <an*******@hotmail.IHATESpam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Ok, thanks to a kind person yesterday, I've started using the
FindControl()
method. Although I able to get this to work for Web Controls, I'm unable
to
find the HTML Controls? Am I missing something still? Do I really have
to
use the Web controls in order to be able to change properties on the
control?

I'm trying to create a user control and have the apsx page include that
control, but change a few properties, like the Table Border size, or the
HTMLInputText.Name on a text field. Possible? FindControl() doesn't seem
to work unless it's a Web control... Am I missing something?

Thanks in advance!
Andrea

Nov 18 '05 #2
No they weren't.... I didn't even think of that, but now that you suggest
it, it makes sense. Although when I tried to add it visa the Properties
yesterday, the runat property is greyed out (I guess that's why I thought it
wasn't needed). I typed it manually into the HTML tag, and now I'm able to
find it.

THX! It's much appreciated. And so fast. Thanks again!
Andrea

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:Op**************@TK2MSFTNGP10.phx.gbl...
Just to make sure, is the HTML web control associated with runat="server"
i.e it is server-side control? For example: <input type="hidden"
ID="theHidden" runat="server" />

I am asking because FindControl can only locate controls with runat="server" i.e server-side controls.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Andrea Williams" <an*******@hotmail.IHATESpam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Ok, thanks to a kind person yesterday, I've started using the
FindControl()
method. Although I able to get this to work for Web Controls, I'm unable to
find the HTML Controls? Am I missing something still? Do I really have
to
use the Web controls in order to be able to change properties on the
control?

I'm trying to create a user control and have the apsx page include that
control, but change a few properties, like the Table Border size, or the
HTMLInputText.Name on a text field. Possible? FindControl() doesn't seem to work unless it's a Web control... Am I missing something?

Thanks in advance!
Andrea


Nov 18 '05 #3
Shouldn't be any different. However, be aware that Controls can be nested,
but that the FindControl() method only searches the immediate Controls under
a Control. Example:

Form1
Control1
SubControl1
SubControl2
Control2
SubControl3
SubSubControl1

Using the FindControl() method on Form1, you could find Control1 and
Control2. To find SubControl1, you would have to use the FindControl()
method of Control1. To find SubSubControl1, you would use the FindControl()
method of SubControl3.

If necessary, you can write a recursive function that searches all Controls
of a given Control, and then recursively calls itself for each Control in
that Collection.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Andrea Williams" <an*******@hotmail.IHATESpam.com> wrote in message
news:#T**************@TK2MSFTNGP11.phx.gbl...
Ok, thanks to a kind person yesterday, I've started using the FindControl() method. Although I able to get this to work for Web Controls, I'm unable to find the HTML Controls? Am I missing something still? Do I really have to use the Web controls in order to be able to change properties on the
control?

I'm trying to create a user control and have the apsx page include that
control, but change a few properties, like the Table Border size, or the
HTMLInputText.Name on a text field. Possible? FindControl() doesn't seem
to work unless it's a Web control... Am I missing something?

Thanks in advance!
Andrea

Nov 18 '05 #4

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

Similar topics

4
by: MattB | last post by:
This is just a rephrased version of a question I posted earlier. I think I'm closer now, so it seemed worthy of a new (more specific) post. In my repeater I'm dynamically creating text boxes, so...
6
by: D Sheldon | last post by:
I have created a method that accepts a string value (representing the name of a textbox) and then returns the value. Because the name of the textbox can change, I first build a string with the...
7
by: Lau Lei Cheong | last post by:
Hello, I'm using javascript's insertAdjacentHtml() to insert images to the webform at runtime. This runs fine(image successfully displayed at the browser) but when I tried to access the...
5
by: sck10 | last post by:
Hello, I am using the code below to set the values of a DetailsView template field using FindControl. My question is how would you find a control if its a Boundfield control? For example,...
2
by: Bruno Alexandre | last post by:
Hi guys, I have this code: Dim gv As GridViewRow Dim str As String = "" Dim dd As DropDownList For Each gv In gvItems.Rows If gv.RowType = DataControlRowType.DataRow Then
2
by: ThunderMusic | last post by:
Hi, I have a custom WebControl. I fire an event and send, as the EventArg, another WebControl that contains sub controls (ParseChildren(true))... It can contain anything, but I want to find one...
2
by: kevin | last post by:
Hi. I'm ripping my hair out. I'm in VS 2005 Framework 2. I have one website with a gridview with some template fields. I'm using the footer row to insert records. For this discussion there is a...
5
by: John Kotuby | last post by:
Hi all, After more than a year programming with ASP.NET 2.0 and VB I am still finding it difficult to leave some habits from classic ASP behind. this is particularly true with cross-page posting....
9
by: AAaron123 | last post by:
I'm this far in determining the correct code to find a textbox I need to set. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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
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,...

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.