遗失的星空

导航

【整理】动态加载Web UserControl

protected override void OnLoad(EventArgs e)
{
HttpCookie login_cookie
= Request.Cookies["login_cookie"];
if (login_cookie != null && MyDAL.MyUtility.IsInArray("ucid", Request.QueryString.AllKeys))
{
string ucid = Request.QueryString["ucid"];
string UCID = string.Format(@"~/uc/{0}.ascx", ucid.Replace('.', '/'));
if (System.IO.File.Exists(Server.MapPath(UCID)))
{
UserControl uc
= (UserControl)Page.LoadControl(UCID);
uc.ID
= "uc";
PH_Holder.Controls.Add(uc);
}
}
base.OnLoad(e);
}

posted on 2011-02-16 16:53  遗失的星空  阅读(216)  评论(0编辑  收藏  举报