Hello,
I have created a web page, now i want to add the master page, the problem is i only have to show the master page when the user enters and if the administrator enters the master page should be disabled and it should show the page as it is
void Page_PreInit(Object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
if (Session["login"].ToString() != "admin")
{
this.MasterPageFile = "~/NewMaster.master";
}
}
}
catch (Exception ex)
{
lable1.text = ex.ToString();
}
}
i also tried
this.Page.MasterPageFile = "~/NewMaster.master";
exception:
"Content controls have to be top-level controls in a content page or a nested master page that references a master page"
when i try to put Content controls in the page it gave me:
"ContentPlaceHolder can only be used in .master files."
it is not working.
please help
thank you