Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > FindControl() Question

Reply
Thread Tools

FindControl() Question

 
 
DotNet
Guest
Posts: n/a
 
      02-12-2004
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.


 
Reply With Quote
 
 
 
 
Stefano Mostarda
Guest
Posts: n/a
 
      02-12-2004
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.
>
>

 
Reply With Quote
 
 
 
 
DotNet
Guest
Posts: n/a
 
      02-12-2004
Excellent!. Thanks very much. Worked like a charm.



"Stefano Mostarda" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments