November Happy Hour will be moved to Thursday December 5th.

Problems rendering user controls as EPiServer dynamic content

Vote:
 

Hi,

Im trying to make a EPiServer dynamic content control, the content i want is a usercontrol which i already made(a image slider).

Every thing seems to work just fine until i insert the dynamic content control unto the page/area i want to use it on.

When i now go to the page i have created only the "static" content:

GallerySlider.ascx.cs:

<!-- Slider -->
<cdk:ListOfSliderPages runat="server" ID="stylesList">
...
</cdk:ListOfSliderPages>

<h3> Cant seem to load any of the usercontrols ?</h3> <br/>

<asp:TextBox runat="server" ID="TestTextBox"></asp:TextBox>

<cdk:ListOfSliderPages runat="server" ID="slidesList">
...
</cdk:ListOfSliderPages>
<!-- END Slider -->

 GallerySlider.cs

[DynamicContentPlugIn(
DisplayName = "Gallery slider",
Description = "Displays a slider",
ViewUrl = "~/Pages/CW.Core/UserControls/DynamicContent/Custom/GallerySlider.ascx")]
public partial class GallerySlider : UserControlBase
{
public PageReference SlidesRoot { get; set; }
public IEnumerable<SliderPage> DataSource { get; set; }

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

DataSource = SlidesRoot.GetChildrenOfType<SliderPage>();

stylesList.DataSource = DataSource;
stylesList.DataBind();
slidesList.DataSource = DataSource;
slidesList.DataBind();

TestTextBox.Text = "FooBar";
}

protected string GetStyle(PageData pd, string propertynameBox, string propertynameInverted)
{
if (pd.Property[propertynameBox] != null && pd.Property[propertynameBox].Value != null)
return "box round";
if (pd.Property[propertynameInverted] != null && pd.Property[propertynameInverted].Value != null)
return "inverted";
return "";
}

public bool RendersWithControl
{
get { return true; }
}
}

 On the page only the header and textbox(without the text set serverside) is displayed. And if i try to debug, it never goes serverside at all it seems.

What am i doing wrong ?
Why is the UserControl not rendered ? 

Thanks for any reply.

 

#56148
Jan 09, 2012 12:46
Vote:
 

Not sure if if affects anything, but have you tried changing the DataSource to protected instead of public?

And you have to render your property where you insert the dynamic content with a <episerver:property propertyname="nameofproperty" runat="server" />.

#56152
Jan 09, 2012 14:23
Vote:
 

No we are currently not use the <episerver:property>, it turns out if we do use it, every thing works. So thanks for that.

But we do not wish to use it, we are currently using page type builder to create the page property's.
And if we use <episerver:property> the simple refactoring of a page name doesnt work since you then also have to change the propertyname of the <episerver:property> as well.  

What we use today is this method:

<%= CurrentPage.MainBodyAsPresentationString(this) %>

public string MainBodyAsPresentationString(PageBase currentPage)
{
var mainBodyXHtml = this.GetProperty(page => page.MainBody) as PropertyXhtmlString;
return mainBodyXHtml.ToPresentationString(currentPage);
}

So is there a diffrent way of doing the same as the <episerver:property> ?

#56155
Edited, Jan 09, 2012 15:08
Vote:
 
#56156
Jan 09, 2012 15:14
Vote:
 

I am using the EPiServer Property yet cannot get dynamic content to render, not even when inserting dynamic content (i.e. -  the built-in page property) from TinyMCE.  Any suggestions would be greatly appreciated.

#59946
Jul 06, 2012 9:27
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.