Add Control to Sitefinity Page with Default Permissions

By in
No comments

When adding controls to a Sitefinity page programmatically, by default it’s going to set restricted permissions so that only users in the Administrators role can view them.

You can easily change this so that the widget is installed with the default permissions it would get by being dragged onto the page with the following code:

var ctrl = pageManager.CreateControl<PageControl>("~/Path/To/Control.ascx", "ContentPlaceholderName");
pageManager.SetControlDefaultPermissions(control);
pageData.Controls.Add(control);

View Code Sample on Gist

The following two tabs change content below.

selaromdotnet

Senior Developer at iD Tech
Josh loves all things Microsoft and Windows, and develops solutions for Web, Desktop and Mobile using the .NET Framework, Azure, UWP and everything else in the Microsoft Stack. His other passion is music, and in his spare time Josh spins and produces electronic music under the name DJ SelArom. His other passion is music, and in his spare time Josh spins and produces electronic music under the name DJ SelArom.