Get the visibility of a web part property on code-behind

Cristhian Caldas asked on December 17, 2015 17:16

Hi.

I was created some properties on a web part ; one of them were configured the visibility of it and works on CMS,but i would like to know how to get the visibility of a webpart property on code-behind.

Thanks

Recent Answers


Brenden Kehren answered on December 17, 2015 17:20 (last edited on December 17, 2015 17:21)

This should do the trick as long as your web part inherits from CMSAbstractWebPart

if(Visible)
{

}

The other option is to simply use the StopProcessing property:

protected void SetupControl()
{
    if (this.StopProcessing)
    {
        // Do not process
    }
    else
    {
        // Continue on
    }
}
1 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on December 17, 2015 17:22 (last edited on December 17, 2015 17:23)

GetValue("Visible"); should do this. It will return an object, so you will need to cast it to bool. You could use ValidationHelper class for casting.

0 votesVote for this answer Mark as a Correct answer

Cristhian Caldas answered on December 17, 2015 17:30

Sorry,but i have to clarify that the question is how to get the visibility of a property that were associated to a a webpart, not the visibility of a web part.

Thanks

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on December 17, 2015 18:26

Visibility of a property associated to the webpart? I'm confused.

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on December 17, 2015 19:18

Are you wanting to get a property of a different webpart while in another webpart? Or maybe in the page, you want to check a property on a webpart?

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on December 18, 2015 10:43

Hi,

Do you mean the visibility property of a (custom) property of the webpart?

Like:

list webpart > title field > visibilty

If so you might be able to extract this info using WebPartInfoProvider. You can have a look at the API samples here: https://docs.kentico.com/display/API9/Web+parts#Webparts-Updatingawebpart

Greets,

David

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.