Custom editable Web Part

Dmitry Bastron asked on July 15, 2016 08:58

Hi community!

I want to create a custom editable Grid web part consisting of <cms:EditableText /> controls (or similar with the ability of editing in Edit mode). I've created a web part and inherited it from CMSAbstractEditableWebPart. What methods should I overload or implement to save submitted data and to show saved data for the editor? I couldn't find any helpful examples of custom editable controls creation. Please push me in a right direction.

I saw this method in editabletext.ascx.cs:

public override void LoadContent(string content, bool forceReload = false)

What is the purpose of that method and how should I implement it in case I have a list of editable controls? For a single control it's clear how to save that single "string content" variable.

The main goal is to save and load the data from such editable grid in the custom table.

Recent Answers


Trevor Fayas answered on July 15, 2016 14:56

Whatever you are initiating the "Save" function as, for instance if you place a button and override the onclick. From there loop through your grid's rows, look for CMSEditableText controls and grab their values and save.

For load, usually webparts have a "Setup_Control" function, otherwise a page_load will suffice for loading in your data. IT's still in it's core an ascx control so you can use the various page lifecycle events to set your values up (onInit, onLoad, etc).

Hope that helps! there's on stacktrace some "Find all controls of this type recursively" out there.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.