+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Customizing How a Custom Control Renders in Editor

Customizing How a Custom Control Renders in Editor

3 posts, 1 answered
  1. Eric Marthinsen
    Eric Marthinsen avatar
    12 posts
    Registered:
    20 Jun 2005
    04 Nov 2010
    Link to this post
    Hi. I developed a custom control that wraps an HTML form used to send data into Salesforce.com. The problem I'm running into is that it uses a form tag (without a runat="server"). It works great on the site, but breaks the Sitefinity page editor. After adding it to the page, I can't add any more controls or hit the publish button. Is there a way to have the custom control not render in the editor or to have it render some placeholder HTML?

    Regards,
    Eric
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    04 Nov 2010
    Link to this post
    Hi Eric Marthinsen,

    Thank you for using our services.

    You can check if the current page is in design mode and if it is you can clear the controls collection of the user control and add a literal saying that the control cannot be rendered in design mode:
    protected void Page_Load(object sender, EventArgs e)
    {
        CmsPageBase currentPage = (CmsPageBase)this.Page;
        if (currentPage.PageMode == CmsPageMode.Edit)
        {
            this.Controls.Clear();
            Literal literal = new Literal();
            literal.Text = "the control cannot be rendered in design mode";
            this.Controls.Add(literal);
        }
        else
        {
            //other control logic
        }
    }


    Greetings,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  3. Eric Marthinsen
    Eric Marthinsen avatar
    12 posts
    Registered:
    20 Jun 2005
    04 Nov 2010
    Link to this post
    Thanks! Perfect amount of detail.
Register for webinar
3 posts, 1 answered