locked
System.Web.UI.Control.Visible not working? RRS feed

  • Question

  • User1778575546 posted

    Let's say you have a custom control inheriting from System.Web.UI.Control of which you have overridden the Render method. Inside the ASPX you have entered like so:

    <acme:CustomControl ID="myCtrl" runat="server" Visible="false" />
    In the page's Page_Load method in the code behind (cs) you want to set the visibility to true if certain criteria is met:
    this.myCtrl.Visible = true;
    The control is still not displayed, it seems like the Visible property is not set to true, but remains false.
    What am I doing wrong? Or is it a bug of the .NET framework 
    Wednesday, June 4, 2008 5:49 AM

Answers

  • User-667042492 posted

    hi raybiez,

    do you have a property in your custom control class named Visible? if so, how did you declare it?

    [Bindable(true), Category("Behavior"), DefaultValue(""), Description("Visibility")]public override bool Visible

    {

    get

    {

    bool b = (bool)ViewState["Visible"];return (b == null ? (_visible == null ? true : _visible ) : b);

    }

    set

    {

    _visible =
    value;ViewState["Visible"] = _visible;

    }

    }

    if not has a property named Visible, doesnt matter..Also System.Web.UI.Conrol namespace correspond it..

     second one, how is your Render method?

    regards..

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 5, 2008 5:18 AM