Try our conversational search powered by Generative AI!

how to make checkbox checked by default in episerver



Can any one please tell me how to make checkbox checked(true)  by default  in editor view 

Thanks in advance


Oct 28, 2016 17:01

Two ways

First the old, ugly and not to use way (that must be used before epi version 7), set the default value inside admin

Second the new shiny good way: Set default value to true in your code definition for the pagetype:

//Sets the default property values
public override void SetDefaultValues(ContentType contentType)
   base.SetDefaultValues(contentType);     //Set up your defaults here 

Read more here:

Oct 28, 2016 17:22

You could also revert the logic, I usually do that.

Ex, instead of having ShowSomething that is checked, you could have HideSomething that is unchecked and check it only when necessary.



Oct 31, 2016 11:10

// This approach works for already created pages as well. If you are using SetDefaultValues, that will work only when you create a new page.

Oct 31, 2016 11:11
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.