I have a masterpage
which has a usercontrol
( changecity.ascx
) on it. Now I am using same master page on 2 aspx pages:
But I want to show changecity.ascx
on selectcity.aspx
only.
I can set it s visibility from child pages but I don't want to do that because page events of
changecity.ascx` were still firing.
I want it to be completely removed from masterpage
so that no events of changecity.ascx
should be fired.
What i did so far :--- I removed the control from masterpage
in signup.aspx
's preinit
event. but page life cycle events of changecity.ascx
are still firing. How can I prevent that.
You can try to load your control in codebehind and add it to the page. If you just try an if in the .aspx it will be renderd but just not outputted.
aspx:
<asp:placeholder id="changeCityControl" runat="server" />
Codebehind:
ChangeCityControl ccControl = (ChangeCityControl)LoadControl("/changecity.ascx")
if (renderChangeCityControl){
changeCityControl.Controls.Add(ccControl);
}
See this microsoft page for details.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.