Question

I have two masterpages, one is the "base" Masterpage and the other is a nested Masterpage.

In a subfolder of my asp.net web app, the nested masterpage is referencing the main "Standard.Master" by declaring -> MasterPageFile="~/Standard.Master".

I am using child-contentplaceholders inside the placeholders defined by the base-Masterpage, to host specific content for the pages displayed using the nested masterpage.

Example:

<asp:Content ContentPlaceHolderID="filter" runat="server">
    <asp:ContentPlaceHolder runat="server" ID="filter"></asp:ContentPlaceHolder>
</asp:Content>
 <asp:Content ContentPlaceHolderID="ContentPlaceHolderMain" runat="server">
     <asp:ContentPlaceHolder runat="server" ID="ContentPlaceHolderMain">   
</asp:ContentPlaceHolder>

The contentplaceholder "filter" is defined in the Standard.Master and contains dropdowns or other controls for selecting parameters for the current page, here's an example:

<asp:Content ContentPlaceHolderID="filter" runat="server"> 
   <asp:CheckBox ID="weekCbx" runat="server" AutoPostBack="false" />

I have many objectdatasources that reference these filters like this:

<asp:ObjectDataSource ID="myDatasource" runat="server" TypeName="BusinessLogic.MyType"
    SelectMethod="GetData" 
    <SelectParameters>         
        <asp:ControlParameter ControlID="filter$weekCbx" Name="weeks" PropertyName="Checked" />
 </SelectParameters>
</asp:ObjectDataSource>

Referencing the contentplaceholder in Standard.master like this -> "filter$weekCbx" doesn't work in the nested page. The error is: Could not find control 'filter$weekCbx' in ControlParameter 'weeks'. Using "filter$filter$weekCbx" did not work.

How can I get to the controls inside "filter" placeholder in Standard.Master from the nested page?

If I have to move it to the code behind, I will probably have to use FindControl to access 5-10 filters each time. I would like to avoid that.

Was it helpful?

Solution

You could accomplish this using Strong typed Master Pages, you could find information in Here and Here.

I would suggest that you rethink your design, maybe a couple of things you could change there if you find yourself stuck doing this.

Good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top