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

How to reference an object in a user control from its parent page

I have a page which has a user control called CheckOutStatusBar and it lives
in a table call like this:

<%@ Register TagPrefix="uc1" TagName="CheckoutStatusBar"
Src="Navigation/CheckoutStatusBar.ascx" %>
html.....
<td>
<uc1:checkoutstatusbar id="CheckoutStatusBar1"
runat="server"></uc1:checkoutstatusbar>
</td>

I need to change the formating of a link button in CheckoutStatusBar.ascx
from its parent page. How an I get a reference to it from the parent page?

Thanks.
--
mo*******@nospam.com
Nov 18 '05 #1
4 1284
All you do is put a declaration into the page:

Protected WithEvents CheckoutStatusBar1
As "ProjectName"."UserControlClassName"

and then it becomes available to you in code.

hope this helps
-----Original Message-----
I have a page which has a user control called CheckOutStatusBar and it livesin a table call like this:

<%@ Register TagPrefix="uc1" TagName="CheckoutStatusBar"
Src="Navigation/CheckoutStatusBar.ascx" %>
html.....
<td>
<uc1:checkoutstatusbar id="CheckoutStatusBar1"
runat="server"></uc1:checkoutstatusbar>
</td>

I need to change the formating of a link button in CheckoutStatusBar.ascxfrom its parent page. How an I get a reference to it from the parent page?
Thanks.
--
mo*******@nospam.com
.

Nov 18 '05 #2
Hi,

CheckoutStatusBar oCheckoutStatusBar1 =
FindControl("CheckoutStatusBar1");

but you need to expose public or internal function from your user
control that will handle link formating change.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3
Thanks that was perfect.

--
mo*******@nospam.com
"Sergey Poberezovskiy" <an*******@discussions.microsoft.com> wrote in
message news:18*****************************@phx.gbl...
All you do is put a declaration into the page:

Protected WithEvents CheckoutStatusBar1
As "ProjectName"."UserControlClassName"

and then it becomes available to you in code.

hope this helps
-----Original Message-----
I have a page which has a user control called

CheckOutStatusBar and it lives
in a table call like this:

<%@ Register TagPrefix="uc1" TagName="CheckoutStatusBar"
Src="Navigation/CheckoutStatusBar.ascx" %>
html.....
<td>
<uc1:checkoutstatusbar id="CheckoutStatusBar1"
runat="server"></uc1:checkoutstatusbar>
</td>

I need to change the formating of a link button in

CheckoutStatusBar.ascx
from its parent page. How an I get a reference to it

from the parent page?

Thanks.
--
mo*******@nospam.com
.

Nov 18 '05 #4
"moondaddy" <mo*******@nospam.com> wrote in message
news:uL**************@TK2MSFTNGP09.phx.gbl...
I have a page which has a user control called CheckOutStatusBar and it lives in a table call like this:

<%@ Register TagPrefix="uc1" TagName="CheckoutStatusBar"
Src="Navigation/CheckoutStatusBar.ascx" %>
html.....
<td>
<uc1:checkoutstatusbar id="CheckoutStatusBar1"
runat="server"></uc1:checkoutstatusbar>
</td>

I need to change the formating of a link button in CheckoutStatusBar.ascx
from its parent page. How an I get a reference to it from the parent

page?

It's best if you treat user controls like class instances (which they are).
This means that a user control shouldn't be exposing its link buttons to
the outside world. Instead, the user control should expose a method or
property which allows the link button formatting to change. For instance, in
the user control:

private bool _linkUnderlined = true;
public bool LinkUnderlined
{
get {return _linkUnderlined;}
set
{
_linkUnderlined = value;
if (_linkUnderlined)
{
lnkLinkButton.Styles["text-decoration"] = "underlined";
}
else
{
lnkLinkButton.Styles["text-decoration"] = "none";
}
}
}
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #5

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

Similar topics

0
by: José Newton Fernandes Ferreira | last post by:
Hi, I am migrating a VB 6 ActiveX Control to a C# user control. The activeX control use mshtml to get a reference of document object where it is site on (the html page) to make some decisions. I...
1
by: Martine | last post by:
Hi there! I have a problem with programmatically adding user controls to my mobile webforms. If I load my usercontrol programmatically (in the Page_Load), the object is instantiated, I have...
9
by: Max | last post by:
How do I reference a datagrid on a page from a user control on that page? In my user control, I'd like to have something like this... MyDataGrid being on the page, not in the user control... I...
2
by: Chris Kettenbach | last post by:
Good Morning, I have a user control I dynamically load in the page_init event into a asp:placeholder control. This page also has another placeholder I would like to dynamically load controls into...
7
by: Samuel | last post by:
Hi, I am building a page that makes use of user control as a templating technique. The following is that I have in mind and it is actually working: Root/ -- login.aspx -- login.aspx.vb --...
3
by: Angel | last post by:
How do I get the reference of the IFrame from the asp.net webpage that is being displayed within that IFrame? In other words I have an IFrame in my page. Within that IFrame Set the source to a...
13
by: Michael | last post by:
I have setup a public variable in the Master Page "code-behind-file". Now I would like to set that value from the UserControl, but I can't seem to find a way to do this. Does anyone have any ideas?...
10
by: Richard Lewis Haggard | last post by:
I've created in form that has tab controls that contain tab controls that host user controls on each tab page. It compiles and runs just fine but the designer view fails with a "A circular control...
2
by: Simon Rigby | last post by:
Hi folks, A bizarre problem I am having. I have a treeview which is bound to an XmlDataSource. The XMLDataSource.Data property is set to the result of a function that generates an XML...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.