http://dannyr.cnblogs.com/archive/2004/10/13/51530.aspx
MainPage文件:WebForm1.aspx
WebForm1.aspx.cs
ASCX文件:search.ascx
MainPage文件:WebForm1.aspx
>
WebForm1.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace TestMasterPage
}
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace TestMasterPage
}
ASCX文件:search.ascx
search.ascx.cs
namespace TestMasterPage.Skins.controls
执行顺序
WebForm1.aspx.cs> Page_Load() //加载WebForm1.ascx页面
WebForm1.aspx.cs> Page_Load()> PlaceHolder1.Controls.Add(control); //这个时候新加载的control的数据都是空的,包括postback的数据也是空的
search.ascx.cs> OnInit()
WebForm1.aspx.cs> Page_Load() //返回,继续
search.ascx.cs> Page_Load() //加载search.ascx页面
search.ascx.cs> OnPreRender() //生成search。ascx的html,这个时候会加载postback的数据
请发表评论