同じマスターページのコードビハインドを介して、子のマスターページにリテラルユーザーコントロールの値を設定しようとしています。ここで子マスターページのユーザーコントロールへのアクセス先子マスターページコード
は、私が使用していたコードの例を次に示します。
Global.master
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="GlobalContentPlaceHolderBody" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
Template.master(Global.masterの子)
<asp:Content ID="TemplateContentBody" ContentPlaceHolderID="GlobalContentPlaceHolderBody" Runat="Server">
<asp:Literal ID="MyLiteral1" runat="Server"></asp:Literal>
<p>This is template sample content!</p>
<asp:ContentPlaceHolder ID="TemplateContentPlaceHolderBody" runat="server">
</asp:ContentPlaceHolder>
Template.master.cs
protected void Page_Load(object sender, EventArgs e)
{
MyLiteral1.Text = "Test";
}
ContentPage.aspx
< asp:Content ID="ContentBody" ContentPlaceHolderID="TemplateContentPlaceHolderBody" Runat="Server">
</asp:Content>
私はこれを達成することができていたら、私はまた、グローバルテンプレート上のコンテンツにアクセスできるようにする必要があります。コンテンツページを介してマスターページ。
どのようなエラーが表示されますか? – MattH
エラーは表示されませんが、リテラルは更新されていません。 – jpshook
これはばかばかしいかもしれませんが、WebサイトやWebアプリケーションを作成していますか?後で、あなたはあなたのサイトをコンパイルしていませんか? –