SharePoint 2010

SharePoint 2010: Setting Value for Web Part’s Custom Properties while Adding Web Part to Page Programmatically


To set the Custom Properties of web part through code while adding Web Part to Page programmatically, we can use Reflection to do this, Below is code on how to achieve this. if (string.Equals(webPart.GetType().ToString(), “MyCustomWebpart”)) { PropertyInfo[] pinProperties = webPart.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo pinProperty in pinProperties) { if (pinProperty.Name == “Some Property”)… Continue reading SharePoint 2010: Setting Value for Web Part’s Custom Properties while Adding Web Part to Page Programmatically