469,628 Members | 1,201 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,628 developers. It's quick & easy.

find control in user control in master page

Hi,

I'm trying to get UniqueID of a linkbutton.

I have 2 web user controls.
And a master page.

In fisrst web user control there is a datalist.
In datalist ItemCreated event, I try to find a linkbutton control which is
in the second web user control and in another datalist.
My code is like:

this.Page.Master.FindControl("ctl00$UserControl2$D ataList1$LinkButton1")

Any help will appreciated kindly.
Salim
Jul 23 '07 #1
1 24776
Salim,

It looks like you are using the ClientID instead of the server side ID. All
controls have a "regular" server side ID (The ID you see in the properties
window for the control) and a ClientID which is rendered when the html is
output. When finding a control from within the code-behind you should use
the server side ID. Which based on the ClientID should be: LinkButton1.

If you use this it should work:
this.Page.Master.FindControl("LinkButton1")

It's also possible though, that the LinkButton is contained inside another
control (nested) which it looks like it may be (your "DataList"). So if that
is the case you'll need to find the top-level control on the master page and
then do a find control inside each control moving into each one until you
get to the control you need.

(i.e.

DataList MyDataList = (DataList) this.Page.Master.FindControl("DataList1");
LinkButton MyLinkButton = (LinkButton)
MyDataList.FindControl("LinkButton1");

Regards,

--
S. Justin Gengo, MCP
justin@aboutfortunate[-NoSpam-].com

Free code library at:
www.aboutfortunate.com


"Salim" <sa****@operatech.com.trwrote in message
news:uR**************@TK2MSFTNGP05.phx.gbl...
Hi,

I'm trying to get UniqueID of a linkbutton.

I have 2 web user controls.
And a master page.

In fisrst web user control there is a datalist.
In datalist ItemCreated event, I try to find a linkbutton control which is
in the second web user control and in another datalist.
My code is like:

this.Page.Master.FindControl("ctl00$UserControl2$D ataList1$LinkButton1")

Any help will appreciated kindly.
Salim
Jul 23 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by caldera | last post: by
reply views Thread by Tommy | last post: by
1 post views Thread by lior | last post: by
reply views Thread by robgallen | last post: by
3 posts views Thread by Stimp | last post: by
3 posts views Thread by Cirene | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.