0

My custom property is declared like every example out there:

    [WebBrowsable(true)]
    [WebDisplayName("Group By Date")]
    [Description("Group Articles by date")]
    [Personalizable(PersonalizationScope.Shared)]
    [Category("Extended Settings")]
    public bool GroupByDate
    {
        get { return _groupByDate; }
        set { _groupByDate = value; }
    }

The control is databinding it:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AnotherTestPart.ascx.cs" Inherits="FeatureElements.WebParts.AnotherTestPart.AnotherTestPart" %>
<div><%: GroupByDate %></div>

It displays in the edit region:

Displays in the Edit region I have added the custom property to the .webpart file and removed it and neither variation makes a difference.

enter image description here

Why won't this webpart persist the custom property value? Do I need to have this value present on a list on the site? Is there an event I need to wire the property up to? Is there a Sharepoint setting that could be blocking custom property persistence?

2
  • The property means the custom property code you added to .webpart file? Commented May 26, 2017 at 3:11
  • yes. I'll update the description.
    – Fluffy
    Commented May 26, 2017 at 3:16

1 Answer 1

0

Please try this It will may help you

 [WebBrowsable(true), 
   Personalizable(PersonalizationScope.User), 
   WebDescription("Group Articles by date"),
   Category("Extended Settings"), 
   WebDisplayName("Group By Date")]
   public bool GroupByDate
   {
       get { return _groupByDate; }
       set { _groupByDate = value; }
   }
4
  • Thanks. But, I want the property set for all users. Not per user.
    – Fluffy
    Commented May 26, 2017 at 13:07
  • Did you try adding DefaultValue attribute? Commented May 26, 2017 at 15:09
  • If I add a DefaultValue attribute and initialize it in the constructor, it does set the value. However, changing the value in the edit part does NOT persist the change.
    – Fluffy
    Commented May 26, 2017 at 19:00
  • This answer is not helpful. If anyone has another idea regarding webpart deployment or maybe sharepoint configuration, I'd be all ears. Seems like I'm doing this properly from a code standpoint.
    – Fluffy
    Commented May 31, 2017 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.