0

I've created WebControl by extending Sitecore.Web.UI.HtmlControls.Control class and implemented DoRender method. Adding either in another control or by adding to xml file don't call DoRender method at all. Possible exist any config setting or something else?

using Sitecore.Web.UI.HtmlControls;


namespace Foundation.SitecoreExtensions.HtmlControls
{
    public class UnorderedList : Control
    {
        public UnorderedList()
        {
        }

        protected override void DoRender(System.Web.UI.HtmlTextWriter output)
        {
            output.Write($"<h1>HelloWorld<h1>");
        }
    }
}

Add to xml file not working.

<?xml version="1.0" encoding="utf-8" ?> 
<control xmlns:def="Definition" xmlns="http://schemas.sitecore.net/Visual-Studio-Intellisense">
  <WorkboxCommand>
    <Inline RollOver="true" Class="scRollover" Click="$Command">
      <ThemedImage Src="$Icon" Width="16" Height="16" Align="absmiddle" />
      
      <Literal Text="$Header"/>
    </Inline>

    <UnorderedList></UnorderedList>
  </WorkboxCommand>
</control>

Add by another webcontrol not working though sitecore controls are working.

UnorderedList unorderedListControl = new UnorderedList();

webControl.AddControl(unorderedListControl);
webControl.Controls.Add(unorderedListControl);
rcontrol.Controls.Add(unorderedListControl);

1
  • Show some code, show screenshots from where you try to add it. Show Sitecore content tree with your new control Dec 21 '20 at 12:45
0

To use custom controls you have to add namespace and assembly with your custom code to config in my case:

<controlSources>
<source assembly="Foundation.SitecoreExtensions" namespace="Foundation.SitecoreExtensions.HtmlControls" prefix="html" mode="on"/>
</controlSources>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.