Since the controls exist on the page, not the control, you should find them on the page:
this.Page.FindControl("cartStatusTrue").Visible = varCartStatus; this.Page.FindControl("cartStatusFalse").Visible = !varCartStatus;
Or similarly if they were in the parent control:
this.Parent.FindControl("cartStatusTrue").Visible = varCartStatus; this.Parent.FindControl("cartStatusFalse").Visible = !varCartStatus;
Of course, also make sure your divs have runat="server" and ID="cartStatusTrue" or ID="cartStatusFalse" .
Edit: Another possibility, which is likely to be improved, would be to move the task to hide the div on the aspx page. You can open varCartStatus as a property of the control and read this property on an aspx page. In your aspx.cs:
this.cartStatusTrue.Visible = this.CartControl.CartStatus; this.cartStatusFalse.Visible = !this.CartControl.CartStatus;
source share