code_junkie

disable usercontrol on the load of master page

Nov 12th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <div class="ucTabCtrl" >
  2. <uc1:TLTabControl ID="ctrlname" runat="server" Visible="False" />
  3. </div>
  4.  
  5. Master Page_load()
  6. {
  7. // checking some condition if true
  8. ctrlname.visible = true;
  9. }
  10.  
  11. public partial class Site1 : System.Web.UI.MasterPage
  12. {
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. if (Page is WebForm1 || Page is WebForm2)
  16. {
  17. webUserControl11.Visible = false;
  18. }
  19. }
  20. }
  21.  
  22. public partial class Site1 : System.Web.UI.MasterPage
  23. {
  24. protected void Page_Load(object sender, EventArgs e)
  25. {
  26. ISpecialPage specialPage = Page as ISpecialPage;
  27.  
  28. if (specialPage != null && specialPage.ShouldDisableUserControl)
  29. webUserControl11.Visible = false;
  30. }
  31. }
  32.  
  33. public interface ISpecialPage
  34. {
  35. bool ShouldDisableUserControl { get; }
  36. }
  37.  
  38. if (null != this.Master)
  39. {
  40. userControl.Enabled = false;
  41. }
  42.  
  43. Dim userControl As WebControl = ContentPlaceHolder1.FindControl("someControl")
  44. If userControl IsNot Nothing Then
  45. CType(userControl, WebControl).Enabled = False
  46. End If
Add Comment
Please, Sign In to add comment