<asp:Panel ID="PlaceHolderPanel" runat="server">
</asp:Panel>
2. add control loading code to codebehind :
string AlreadyLoaded=null;
private void loadControl(string ctr){
if (!string.IsNullOrEmpty(ctr) && AlreadyLoaded!=ctr ) {
Control ctrl = LoadControl(ctr);
ctrl.ID="ctr1";
PlaceHolderPanel.Controls.Clear();
PlaceHolderPanel.Controls.Add(ctrl);
ControlName = ctr;
AlreadyLoaded=ctr;
}
}
protected void Page_Load(object sender, EventArgs e){
loadControl("~/Controls/mycontrol.ascx");
}
There are limitations for loaded controls , one of them using onPreRender rather then Page_load:
// 1.call all functions in prerender only
protected override void OnPreRender(EventArgs e){
SetFilterValues();
Bind();
base.OnPreRender(e);
}
No comments:
Post a Comment