473,474 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

FindControl() Question

I'd like to capture an attribute of one control from another control called
in the same ASPX page. I can get the ID value, but no other attributes. How
does one do this?

Control MyControl = Parent.FindControl("HeaderTemplate");
if(MyControl != null) {
Response.Write("Value: " + MyControl.ID); //this works fine.
Response.Write("Value: " + MyControl.Section); //this doesn't
work!
Response.Write("Value: " + MyControl.Attributes("Section"));
//this doesn't work either!
}

Thanks.
Nov 18 '05 #1
2 934
Hi,

You have to cast the HeaderTemplate object.
For instance if HeaderTemplate is a DataGrid, you have to cast it to the
datagrid type and then use it.

((DataGrig)HeaderTemplate).AnyPropertYouWishToUse

Hope this helps.

Stefano Mostarda MCP
Rome Italy

DotNet wrote:
I'd like to capture an attribute of one control from another control called
in the same ASPX page. I can get the ID value, but no other attributes. How
does one do this?

Control MyControl = Parent.FindControl("HeaderTemplate");
if(MyControl != null) {
Response.Write("Value: " + MyControl.ID); //this works fine.
Response.Write("Value: " + MyControl.Section); //this doesn't
work!
Response.Write("Value: " + MyControl.Attributes("Section"));
//this doesn't work either!
}

Thanks.

Nov 18 '05 #2
Excellent!. Thanks very much. Worked like a charm.

"Stefano Mostarda" <st**************@fastwebnet.it> wrote in message
news:uj**************@TK2MSFTNGP12.phx.gbl...
Hi,

You have to cast the HeaderTemplate object.
For instance if HeaderTemplate is a DataGrid, you have to cast it to the
datagrid type and then use it.

((DataGrig)HeaderTemplate).AnyPropertYouWishToUse

Hope this helps.

Stefano Mostarda MCP
Rome Italy

DotNet wrote:
I'd like to capture an attribute of one control from another control called in the same ASPX page. I can get the ID value, but no other attributes. How does one do this?

Control MyControl = Parent.FindControl("HeaderTemplate");
if(MyControl != null) {
Response.Write("Value: " + MyControl.ID); //this works fine. Response.Write("Value: " + MyControl.Section); //this doesn't work!
Response.Write("Value: " + MyControl.Attributes("Section"));
//this doesn't work either!
}

Thanks.

Nov 18 '05 #3

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

Similar topics

3
by: Andrea Williams | last post by:
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...
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.