3

I want to be able to load, edit (from the UI) and save this config settings somewhere in the Sharepoint server. How do I do this?

EDIT: config settings - The values of my UI elements.

For example: I have a checkbox in my webpart and i need to load, edit (from the UI) and save it's value.

  • Could you detail what you mean by "config settings"? – moe Jun 1 '17 at 15:44
  • @moe, Thanks for the response. I have updated the question, config settings - The values of my UI elements.. – Rajagopal 웃 Jun 1 '17 at 15:51
  • The terminology is still confusing, which is why I'd ask for further explanation: Do you want to do changes to your page's elements (in SharePoint terms web parts), or do you want to do changes to the CSS (in SharePoint terms style sheets), or something completely else? – moe Jun 1 '17 at 15:57
  • I have a checkbox in my webpart and i need to load it from my last change. – Rajagopal 웃 Jun 1 '17 at 16:24
2

We've always used a SharePoint list in the past, and it still works well today. Since a SharePoint app is going to be specific to a site or web, it makes sense to make the configuration for the SharePoint app configuration settings come from a SharePoint list. It can be on the host web or on the app web, depending on the kind of SharePoint app you are deploying.

  • Mike, Saving the state in the list wouldn't help us. Because, i will use the same list with different configurations. For example, showing the SharePoint list in my webpart will vary based on the selected configurations. Saving these configurations along with SP List wouldn't make sense until it was a webpart setting. – Rajagopal 웃 Jun 1 '17 at 16:29
  • That depends on your list. I've had it where there was a multivalue text field that holds a json value, that you can edit at any time. Also, the webpart setting is based on your SharePoint app, so that has to be changed on the app side. Also you could reference a javascript file that is in the host app that will change the behavior of the webpart based on settings--if that's what you are getting at. You can change the javascript logic on the fly without redeploying. – Mike Jun 1 '17 at 16:43
  • Also, for user-specific settings - I would suggest using the session storage: developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage – Mike Jun 1 '17 at 16:54
  • Mike, actually i have used the "[Personalizable(PersonalizationScope.Shared), WebBrowsable(false)]" property in my SP 2010 webpart. But, i have no idea about using the C# code for latest version. stackoverflow.com/questions/44286861/… – Rajagopal 웃 Jun 1 '17 at 18:52
  • I think you may be looking for app part properties (since it's a SharePoint App): Look here -- dotnetmafia.com/blogs/dotnettipoftheday/archive/2013/01/04/… – Mike Jun 1 '17 at 19:10
0

I've generally used the SPWeb.Properties to store configuration specific to that web or that instance. You create a name-value pair and store that in the web.properties that you can get to either through JavaScript or through the object model. An added bonus of this is that you can retrieve/set these through SharePoint designer which can save you the trouble of creating a UI for your application settings.

See this: Object Model or Javascript Side

  • #1) I don't think it possible to write a C# code in latest versions. Could you please tell us on how to create a C# code in sharepoint 2013 online add-in? #2) Is it possible to hold the long string value(something like paragraph) in this properties? – Rajagopal 웃 Jun 1 '17 at 18:46
  • Check the second link, it show you how to do the same thing with JavaScript on the client side. – Peter Joyce Jun 1 '17 at 20:26
  • In second link the value can be passed as a query parameter. Will that work for a long string something like a paragraph? – Rajagopal 웃 Jun 2 '17 at 7:40
  • I have tried as you mentioned in the second link, values for properties must to set whenever the page reloads. But, i want to get the previously saved value. – Rajagopal 웃 Jun 2 '17 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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