Add a Generic Content to a User ControlCancel

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.

Hi all,I'm hoping for a pointer on where to start. The developer guide has a section that seems just like what I need to do but I'm not super familiar with sitefinity or asp.net yet to put it all together. here's what I want to do:

Our site layout has a sidebar on the right. The CSS template we are using has a class called "sidebox" which when applied to a div tag which creates a simple gray box container. Users can drop a Generic Content control onto the sidebar but then they would need to go into HTML view and create a div wrapper around their content with the class="sidebox" element in order to get the gray box around their text. Not all text in the sidebar would be in a sidebox. So I thought it would be a good user experience to wrap the Generic Content control in a customer user control which simply puts the div with the sidebox class around that instance of the Generic Content control.

I followed, best I could, the example in the user guide, but the result is that I cannot edit the contents of the Generic Content but can only set the properties for it.

Is this the best approach to do what I'm considering here? It's on v 3.2 + Sp2 + hotfix. If there are any examples of this sort of thing please let me know.

I have attached an example that demonstrates how to achieve the required functionality. Also, you can find a detailed explanation about wrapping GenericContent control in a user control in the Developer Manual.

I had followed the instructions in the Developer Guide (the same link you sent) but the control I made didn't work. I compared to your code and saw that I missed the IContentContainer inheritance on the class.

Before I post by question, I noticed that there is an information icon above that states "Before posting make sure your project is using the exact
same RadControl version as the one in this thread.
This is an old post and the information may be outdated." This is Sitefinity, so I would first have to dif around to see which radcontrols are used in my version of sitefinity but would have to compare to sitefinity 3.X and "X" could be anything and the "X" can make a BIG difference, so this "warning" is completely useless.

I am having trouble with finding out how to do something and the major differences between the versions makes it very hard to find any answers.

This thread show a very easy way to create a user control that simply wraps the generic content control in a "div". This does not work in sitefinity 3.6. Is there an equal or easier way in sitefinity 3.6 to do this? Since the CssClass property was taken away from the generic content (even though it still shows up as a possible property, wasting the time of users that of course assume something that exists in the properties would have an actual function)

Thanks, I've taken a look at the link provided. However, I wanted to confirm that the method decribed in that link is the only method that works on Sitefinity 3.6 SP2? It seems overy complex for only wrapping the output of the generic content control in a DIV tag. For instance, the method used further up in this thread uses a very simple user control, like this:

This simple user control actually works in 3.6 SP2, except the "this.GenericContent1.ProviderName = value;" line generates an error when you use the control and type in text into the control and try to set the content, because "value" is null. Commenting out this line makes it work. Though I'm not sure if there are any "hidden" issues doing this.

The code should not produce error when there is no provider set, since Provider name is implemented from IContentContainer interface. The ProviderName property gets or sets the name of the data provider that will be used to retrieve shared content. If the value is empty or null, the default data provider will be used.
Also, ProviderName can be persisted as a ViewState. By doing so we will ensure that Generic_Content provider will be set as default provider every time you drop the control on a page.

Tools

Sitefinity Professional Services

Progress, Telerik, Sitefinity and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries.