473,406 Members | 2,847 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,406 software developers and data experts.

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 24976
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: caldera | last post by:
Hi, I want to find the web user control in the datalist. I iterate the datalist using foreach statement in the DataListItem and in thi DataListItem I iterate all Controls objects but I can't find...
0
by: Tommy | last post by:
I am working on a site that uses a menu control. Because I need more than one master page for different looks I put the common controls in webcontrols and use them in the master pages to maintain...
2
by: Rado | last post by:
Hello. Can anybody write me some links, where can I find some good manual for writing own windows control? Thanks.
5
by: Aussie Rules | last post by:
Hi, Within the code of a content page, how do you say set the .text value of a label thats on the master page.... Thanks
1
by: thejackofall | last post by:
I can use a good help here with what looks like a simple problem. I have a control called Header.ascx in /Control/System directory, where / is my web application directory. The header is used...
1
by: lior | last post by:
Hello, I have a treeview control that I use as a menu & navigation control within a master page. The nodes for this control are loaded from a database. Is there any simple method of...
0
by: robgallen | last post by:
I have 2 user controls within a master page, and I would like one of them to call a function in the other. All the examples I have seen involve a page communicating with the Master page, or with...
3
by: Stimp | last post by:
I have a few master page files on a large site. I want them all the share the same footer, but I don't want to re-enter the footer text on all of them. So I logically thought I could add a web...
3
by: Cirene | last post by:
When you set the value of a user control in a master page, do you have to reference it differently? Also, do they have to be given different names in the templates? For example, this is what I...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
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...

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.