Hi
How to UnRegister or Hide User Control in Code Behind on a particular Page
<%@ Register Src="~/User/SideBar.ascx" TagPrefix="uc1" TagName="SideBar" %>
Thanks
Hi
How to UnRegister or Hide User Control in Code Behind on a particular Page
<%@ Register Src="~/User/SideBar.ascx" TagPrefix="uc1" TagName="SideBar" %>
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Jan 28, 2023, 3:15 AM EST
Test this if Output Cache is not enabled.
protected void Page_Load(object sender, EventArgs e) { var masterPage = Master; if (masterPage != null) { (System.Web.UI.UserControl)masterPage.FindControl("uc1")).Visible = false; } }Naimish MakwanaRank #324 · 7.7K reputationPosted Jan 30, 2023, 3:12 AM EST
Hello Ramco
Please use below code
protected void Page_Load(object sender, EventArgs e) { var masterPage = Master; if (masterPage != null) { masterPage.FindControl("uc1").Visible = false; } } }In case of Output Cache is enable than please refer below link.
https://www.codeproject.com/Articles/444421/How-to-manipulate-master-page-controls-in-ASP-NET
Thanks
Naimish