SharePoint 2013 Visual Webpart Sandbox solution

Veeru Dasa 21 Reputation points
2021-06-02T20:27:08.097+00:00

Hi All,

we are looking at creating dynamic pages without the need to create custom lists to create resources like tiles and cards. Perhaps it could webpart which will allow users to add complex resources (e.g. card with title, description, image, link) within a page. In this case, the details would have to be stored dynamically somewhere. We don't want to have to create a list every time someone has to use a similar element.

Created Visual webpart with custom String property and trying to save JSON(collected details from the form) to the custom webpart property on form submit. but the set property doesn't working as expected.

Is there any other better way to achieve this task. Please help, Thanks in Advance

Regards,
Veeru

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,581 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,784 questions
0 comments No comments
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,021 Reputation points
    2021-06-03T08:59:51.733+00:00

    Hi @Veeru Dasa ,

    Saving the data to the custom webpart property will not work for you. The property would be reseted, the default values would be forcefully placed in the properties.

    The best way is to save the data to store the data in a list. You just need to create a list to store the data. Just update the list item or add a new item to this list.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Veeru Dasa 21 Reputation points
    2021-06-03T16:06:51.663+00:00

    Hi Micheal, Thanks for the response

    can we set the property using client-side code ? we don't want to store data into list. on the fly when the user submits form it needs to store data into the page and get the data from the page itself.

    Is there any alternative solution for this requirement ?

    Regards,
    Veeru

    0 comments No comments

  2. MichaelHan-MSFT 18,021 Reputation points
    2021-06-04T05:43:46.633+00:00

    Hi @Veeru Dasa ,

    You could use JSOM code to set the custom property through SP.WebParts.WebPart Properties.

    Refer to this blog to set the WebPart Properties: https://blog.josequinto.com/2015/09/30/update-webpart-properties-jslink-using-jsom-in-sharepoint-2013-office-365/#Introduction

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.

    In above article, it's updating the JSLink property of the web part. Per my test, it's worked for custom property. You just need to change to your custom property like this:

    properties.set_item("customProperty", "test");  
    
    0 comments No comments