Kentico Widgets :: Matching fields with HTML structure of Web Part

Kurt Muller asked on December 28, 2017 14:50

I really hope I'm making sense with this one. I'm trying to create a widget from a custom webpart that I created. It's nothing special at all as you can see:

<h3>Header</h3>
<p>Intro Copy</p>
<ul>
    <li>List item one</li>
    <li>List item two</li>
    <li>List item three</li>
</ul>

I now want to be able to create a widget from this and create new fields that will be used to populate the above DOM. What do I need to do in order or do this.

In an example I saw for the demo site, they populated the bg image with:

style="background-image: url('{% ResolveUrl(PathToImage) %}');"

That was however done on the front facing part of the CMS and I'm trying to do it within the solution.

Any thoughts?

Recent Answers


Brenden Kehren answered on December 28, 2017 15:08 (last edited on December 28, 2017 15:09)

It's all in your layout or code behind. Your layout can have that code (but in ASCX format) and it will work just fine. OR you can add literal controls to the page based on the fields and what the user has entered.

Doing it in your layout is more restrictive and specific to that one application but allows you to use multiple new webpart layouts. Using the code approach allows you to be more dynamic but doesn't allow you to use the built-in layouts of the webpart/widget.

Also no need to cross-post to SO as SO will bring the questions to DevNet as long as they are tagged "Kentico".

0 votesVote for this answer Mark as a Correct answer

Kurt Muller answered on December 29, 2017 08:21

Thanks Brendon

I will have a look at both options you've presented. If I run into a stumbling I will definitively post it back here.

Also, thanks for the SO info.

0 votesVote for this answer Mark as a Correct answer

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