user controls containing other user controls

I have a ContactInfo custom class that exposes AddressInfo custom class as property. I created two User Controls, you guess, Contact.ascx and Address.ascx.  Address.ascx exposes property Address as AddressInfo.  I am running into following problem. In Contact.ascx in page_load sub I am trying to set the values of the Contact class like this :


_contact.PrimaryAddress = ctlAddress.PrimaryAddress

but since value of the PrimaryAddress property in Address.ascx is set also in Page_Load, above code will not work since there is no instance of this object yet. Is my only option to make this work to raise an event from child control to notify Contact.ascx that that Address has changed.

You died at the very end of your life
0
exptrade2000
10/6/2004 7:36:34 PM
asp.net.hosting-open-forum 4216 articles. 0 followers. Follow

1 Replies
952 Views

Similar Articles

[PageSpeed] 41
Get it on Google Play
Get it on Apple App Store

I would use databinding.

<cc1:Contact id=foo runat=server PrimaryAddress=<%#bar.PrimaryAddress%> />
<cc2:Address id=bar runat=server />
Then after everything has loaded maybe in prerender just call databind on your control.
0
stevemc
10/6/2004 10:39:27 PM
Reply:

Similar Artilces:

Adding User Controls from Sting can the User Control contain a CompileWith Control directive?
I want to store my User Controls in a DB. So I working with ParseControl and passing it a string. However when I pass as string of a control with codebehind I get this error. My Code: Dim strControl1 As String = "<%@ Control Language=""VB"" AutoEventWireup=""false"" CompileWith=""Control1.ascx.vb"" ClassName=""Control1_ascx"" %>" & vbCrLf & "<div>Control 1<br /><asp:PlaceHolder ID=""Control1PlaceHolder"" Runat=""server""...

User control in a user control
Hello all, I have created a user control with some checkboxes, and public properties to get the values of these checkboxes. I have also created a second user control using the first user control; this second control also access the public properties of the first one. My problem is when I implement the second control in an aspx page, if I click at runtime the checkboxes in the first control, I am able to access its public properties from the methods of the second control but the values of these properties are wrong. while at design time, I do not have this problem. Than...

user control to user control
I have an aspx page that have a "Register" directive to two usercontrol called rptMaster.ascx and rptDetail.ascx. I'm trying to set up a Master-Detail relationship and wish for the rptMaster.ascx to trigger and event from a dropdownlist and for the rptDetail to be listening for DropDownList event. I believe I have gotten the events part okay with help from this articel http://codeproject.com/aspnet/Page_UserControl.asp but my declaration for a private statement to my rptMaster class is producing an error. I'm using beta 2 of asp.net and I 'm having trouble getting a reference TO ...

User Control in a User Control
I have a first user control that contain a second user control. If I cahe the first user control can I still dynamically control the second one or it is cached with the first one therefore can not control it anymore? Thanks When your first control is cached, its rendered out and its output is stored in the cache. On every request to the page containing your control that can satisfy it from cache, the output will just simply be inserted - your first control will never be instantiated or run in that case, so the second one wont be either. Hope this helps,Mike VolodarskyProgram Manager...

User Controls in User Controls?
I have the follow set up and it is throwing an error "Unhandled error loading module" ... is there some trick to this that I don't know?I have a project A that uses controls from project B (project B is just a project with all my user controls used through out other modules).  project A uses user control 1 from project B with out any issues at all - great.  But then I wanted to add user control 2 to user control 1 and that is when I get my error.  In fact I don't even have the user control 2 in user control 1, just when I put the register part into user control 1 is when it al...

Can a user control contain another user control?
...? Sincerely,remedyMCP + Senior .NET DeveloperVista: Worth every penny. Yes, of course.Bertrand----This posting is provided "AS IS" with no warranties, and confers no rights. yes! this's ok!no problem!...

User Controls not working if I put Validation controls in user control
Hi           I have validation controls(RequiredField Validator,RegularExpressionValidator)  in user controls.User controls are not posting back like the events are not wiring up.If I remove Validation controls in User controls page,user controls are working fine.Can anyone please help me out in getting it fixed. In the Validation controls, make sure you are setting the ControlToValidate property to the control that it links to.  If you're in .NET 2.0, it's also a good idea to put all the validation controls in the same Valid...

How to access a user control from another user control in a Wizard control
My page has a wizard control and each step is a user control.  I could find the value of a control in step1 user control in the wizard page but not in step2 user control.From wizard.aspx.vb – it worksDim m_title As DropDownList = CType(Me.PersonalBox1.FindControl("ddlTitle1"), DropDownList) Question:How can I find the value of a control(textbox or dropdownlist)in step1 user control from step2 user control? I want to find “PersonalBox1.FindControl("ddlTitle1")” from Step2 AddressBox1. I have tried several ways to access it but no luck. From AddressBox.ascx.vb –...

User Control controls not created when dynamically creating user control
  Have created a user control for displaying and editing a dynamically number of values. The user control contains two labels and an edit box. When dynamically loading the user control I get an error when the control itself tries to change setting on the fields within the user control.   Why doesnt this work? It works okay if I dont load it dynamically but create a user-control-instance in the aspx-page but thats no solution.   Thankyou!     Here is my code:   ucDataValue.ascx   <%@ Control Language="C#" AutoEventWireup="true&...

How to access individual controls from a form containing the web user control containing those controls
 Below is a block of code in my .aspx form named default.aspx. In this form I load a web user control. I then add it to a place holder control.(Lines 3 and 4 below) So how do I access the individual controls in my web user control? I want to set the properties on those controls, but I am baffled as to how to access the control. For example I have a text label control named "label3". How do I access this control. Because for example, under certain situations I want to hide that control. ( Label3.Visible = false;)  1    if(!Page.IsPostBack) 2&nb...

Unable to access user control's user control's function\property from another user control
Hi, I used to call an user control's user control function as stated below from my user control in ASP.Net 1.1 wucCompany.wucEmployee.GetEmployeeSomething() After migrating to ASP.Net 2.0, I am unable to use any properties/functions(even the public ones) of the user control's User control's from another user control.  The way I have to do is create property\function in wucCompany which calls the wucEmployee's property\function and call the wucDepartment.GetEmployeeSomething().Since I need to do this change in too many places, I can...

Inherits user controls from my own user control.
Hi, I am working on ASP.NET 2.0 with the C# as code behind. I have a baseControl.ascx.cs which will have properties and some methods.Then I have childControl.ascx.cs which inherits from  the baseControl. Public partial class childControl : baseControl Both user controls are in the same namespace. When I build those user controls, it returns me error saying that the type or namespace baseControl cannot be found(). I would like to know is it possible to inherit user control? Will it be possible if I declared the baseControl as an abstract class since I want to have some abstract met...

Raiseevent user control in user control
 Hi there, I am working on a project in which a user control (BedrijfMasterDatagrid.ascx) is creating an other user control (BedrijfDatagrid.ascx).The user control BedrijfDatagrid.ascx is correctly created, but the clicked event of the created image control (BedrijfDatagrid.ibImageButtonClicked ) is not fired. (see BedrijfDetail.aspx)When I place BedrijfDatagrid.ascx directly on the page the event is correctly fired. Summary:BedrijfMasterDatagrid.ascx:       Datagrid with 1 row in which BedrijfDatagrid is dynamically createdBedrijfDatagrid.ascx  ...

User Control inside User Control
I have an ASPX with user controls in it called UC1.There is another user control called UC2 within user control UC1.(UC1 - parent , UC2 - child) What I need to do is to pass value of the text box that’s located inside user control UC1 to UC2. This is the code I put into  user control UC1. How to I read it in User control UC2?   Public ReadOnly Property propCountryName() As TextBox Get Return Me.txtCountrygName End Get End Property    Thank you100 years live, 100 years learn You can define a property inside the UC1 and UC2. Pag...

Web resources about - user controls containing other user controls - asp.net.hosting-open-forum

S.E. Cupp: 'Wasteful Exercise' To Address Right's Violent Planned Parenthood Rhetoric
It's almost like some sort of gag reflex from these pundits on the cable "news" shows, and I use that term lightly. You cannot say anything about ...

Obama eyes legacy-defining climate pact
The president is heading to Paris for global talks fraught with political obstacles.

Newborn Baby Girl Survives Abandonment And Attempted Murder
The abandonment of newborn baby girls and boys seems to be an increasing phenomenon in the news lately. Most recent is the story of a baby girl ...

Turkey recovers body of pilot from downed Russian jet
By Dasha Afanasieva and Lidia Kelly ANKARA/MOSCOW (Reuters) - Turkey recovered the body of a Russian pilot from northern Syria and presented ...

Box Office: ‘Hunger Games’ Leads Thanksgiving Pack, ‘Creed’ Scores
Moviegoers said goodbye to Katniss Everdeen and welcomed back Rocky Balboa, a series of farewells and reunions that powered Thanksgiving box ...

Police Urging People To Stay Safe This Holiday Season Following Black Friday Attacks
SACRAMENTO You don't have to say it. We already know what your plans are this holiday season. "Come on. Yesterday was Black Friday. Are you kidding ...

Thousands of Syrian refugee children left in legal limbo
ZAWERGOSK, Iraq (AP) — Aria is stateless. Like thousands of other children born to Syrian refugees living in Iraq, the 10-month-old girl is beginning ...

Tyson Fury Backs Up Boasts, Father’s Prophecy In Win Over Wladimir Klitschko
Tyson Fury wasn’t short on words in the days and weeks leading up to his heavily touted match with WBC Champ Waldimir Klitschko. But the Irish ...

Pope Francis speaks of peace in war-torn Central African Republic
NOLA.com Pope Francis speaks of peace in war-torn Central African Republic NOLA.com BANGUI, Central African Republic — Pope Francis arrived ...

Donald Trump May Not Be A Fascist, But He Is Leading Us Merrily Down That Path
[Cross-posted at Orcinus. ] People who have studied the extremist right as a historical and sociopolitical phenomenon in depth are acutely aware ...

Resources last updated: 11/29/2015 4:21:10 PM