マスターページを使用する場合、マスターページに現在ロードされている、またはロードされているWebフォームを確認できるので、次の行の前に:
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
マスター ページに読み込まれる Web フォームを表示/取得したいのですが、可能ですか?
読み込まれているページにアクセスできるかどうかはわかりませんが、eg というマスター ページにパブリック プロパティを作成し、ページ自体の で必要な値にcurrentPage
設定できます。Page_Load
このようにして、Site.Master コードで確認できます。
// on the Site.Master.cs
public string CurrentPage;
// on the page, inside the Page_Load event
((Site)this.Master).CurrentPage = 'My page';
// on the Site.Master
<%
if (CurrentPage == "My page")
{
%>My page is loaded.<%
}
else
{
%>Another page is loaded.<%
}