Custom Webpart with attachment field type

Shweta S asked on November 5, 2019 20:26


I am building a custom webpart and want to add some fields like Title (Textbox), Description (Rich text editor) and Images (multiple images). My question is there is no form control to upload as many images as I want in the same field.

When I create a page type with a field which uses Attachment form control, I can upload as many images I want in the same field. I want to do the exact same thing for the webpart but the attachment field does not work like it works for the page type.

Correct Answer

Mike Wills answered on November 5, 2019 21:30

Hi Shweta,

You could separate the content from the web part, so that you can use a content-only page type to store the content, including the multiple attachments field. The web part properties would simply allow picking the content, or filtering the content, to be displayed.

I'd suggest separating the content from the web part anyway. This allows changing how the content is displayed, and using it multiple places, without requiring authors to reenter the content. Theoretically, the content could survive a page redesign.

Check out Brenden's answer to this old post. It'll probably get the ideas flowing.


0 votesVote for this answer Unmark Correct answer

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