in Education by
Part of the series of controls I am working on obviously involves me lumping some of them together in to composites. I am rapidly starting to learn that this takes consideration (this is all new to me!) :) I basically have a StyledWindow control, which is essentially a glorified Panel with ability to do other bits (like add borders etc). Here is the code that instantiates the child controls within it. Up till this point it seems to have been working correctly with mundane static controls: protected override void CreateChildControls() { _panel = new Panel(); if (_editable != null) _editable.InstantiateIn(_panel); _regions = new List(); _regions.Add(_panel); } The problems came today when I tried nesting a more complex control within it. This control uses a reference to the page since it injects JavaScript in to make it a bit more snappy and responsive (the RegisterClientScriptBlock is the only reason I need the page ref). Now, this was causing "object null" errors, but I localized this down to the render method, which was of course trying to call the method against the [null] Page object. What's confusing me is that the control works fine as a standalone, but when placed in the StyledWindow it all goes horribly wrong! So, it looks like I am missing something in either my StyledWindow or ChildControl. Any ideas? Update As Brad Wilson quite rightly pointed out, you do not see the controls being added to the Controls collection. This is what the _panel is for, this was there to handle that for me, basically then override Controls (I got this from a guide somewhere): Panel _panel; // Sub-Control to store the "Content". public override ControlCollection Controls { get { EnsureChildControls(); return _panel.Controls; } } I hope that helps clarify things. Apologies. Update Following Longhorn213's Answer Right, I have been doing some playing with the control, placing one within the composite, and one outside. I then got the status of Page at event major event in the control Lifecycle and rendered it to the page. The standalone is working fine and the page is inited as expected. However, the one nested in the Composite is different. It's OnLoad event is not being fired at all! So I am guessing Brad is probably right in that I am not setting up the control hierarchy correctly, can anyone offer some advice as to what I am missing? Is the Panel method not enough? (well, it obviously isn't is it?!) :D Thanks for your help guys, appreciated :) JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I don't see you adding your controls to the Controls collection anywhere, which would explain why they can't access the Page (since they've never been officially placed on the page).

Related questions

0 votes
    I'm looking to build an reusable control or custom helper for my MVC project. I'm sure there is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I'm looking to build an reusable control or custom helper for my MVC project. I'm sure there is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I'm looking to build an reusable control or custom helper for my MVC project. I'm sure there is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I have a scenario where i want to apply cache on a user control in asp.net mvc 2. I have ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I need to integrate IDX MLS into a real estate website. Also I want to know how to implement ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    When Forms Authentication is enabled, once the user provides a username and password it will be validated ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    We currently deploy web applications by creating a database and running SQL scripts through query analyzer. Then ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 29, 2022 in Education by JackTerrance
0 votes
    I am refactoring some CSS on a website. I have been working on, and noticed the absence of traditional ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    Does Server Core 2008 support asp.net? I see references online saying that it isn't supported, but they ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    Does Server Core 2008 support asp.net? I see references online saying that it isn't supported, but they ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I am refactoring some CSS on a website. I have been working on, and noticed the absence of traditional ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    Does Server Core 2008 support asp.net? I see references online saying that it isn't supported, but they ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    Say I have a page that display search results. I search for stackoverflow and it returns 5000 results, 10 per page. Now I ... was posted previously etc.. What I'd like to do is...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    I know how to use the checkboxlist in ASP.NET to display options retrieved from a database. What I ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    Say I have a page that display search results. I search for stackoverflow and it returns 5000 results, 10 per page. Now I ... was posted previously etc.. What I'd like to do is...
asked Mar 19, 2022 in Education by JackTerrance
...