【发布时间】:2011-09-14 11:56:37
【问题描述】:
我有一个母版页和两个具有相同 ContentPlaceHolderID 的内容页。有没有办法指定应该从母版页的Page_Load 事件加载哪个内容页?
如果我看的值:
Request.CurrentExecutionFilePath;
我看到了第一个内容页面的路径。
根据下面指定的条件,我想把它改成第二个内容页的路径。
我正在寻找一种加载特定页面的方法,具体取决于我对 Master Page_Load 所做的检查。
如果我尝试从那里重定向到页面,我会陷入死循环,因为母版页在内容页面之前再次加载并重新进行检查并一次又一次地重定向。
// in master page
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.Cookies["user"] != null)
{
HttpCookie cookie = Request.Cookies["user"];
string name = cookie.Value;
Response.Redirect("~/hello_page.aspx?UserName=" + name);
}
}
}
提前致谢。
【问题讨论】:
标签: asp.net master-pages contentplaceholder