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

Forums / Developing with Sitefinity / ControlDesigner and Embedded Template

ControlDesigner and Embedded Template

4 posts, 0 answered
  1. Eugene Gvozdarev
    Eugene Gvozdarev avatar
    10 posts
    Registered:
    06 Jan 2010
    01 Jun 2011
    Link to this post
    Good day.
    I'm trying to develop my own user control with designer. I'm following the next post:
    http://www.sitefinity.com/blogs/ivan/posts/08-04-23/how_to_create_a_control_designer_for_user_controls.aspx

    Everything works okay. But I have some questions about it.
    1. Can I use template as embedded resource? If yes then how? I understand that I need to set Build Action to Embedded resource. Override LayoutTemplateName to return my template name (something like this "MyProject.Resources.MyTemplate.ascx"). But what I need to do the next? If possible it'll be great to have very simple example.

    2. In the example (link) above User Control uses properties of string[] type. And values of those properties we can change in Designer. But can I use another type of properties? For example List<MyCustomClass> type? I have tried to  implement it but when I click 'I'm done' button in the designer my properties are null.

    Thanks a lot,
    Eugene
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 Jun 2011
    Link to this post
    Hi Eugene,

    Please check this section in our dev manual that provides several topics and samples that show how to create designer for custom controls and use complex properties

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Eugene Gvozdarev
    Eugene Gvozdarev avatar
    10 posts
    Registered:
    06 Jan 2010
    08 Jun 2011
    Link to this post
    Thank you, Ivan!
    That helped. But i have a new problem with it. So
    I edit my Property of List<TabedContentItem> type in the designer.
    Here is TabedContentItem class:
         [Serializable]
        public class TabedContentItem
        {
            public string tabName;
            public string tabValue;
            public string tabURL;
            public string tabContent;
     
            public TabedContentItem()
            {
                tabName = String.Empty;
                tabValue = String.Empty;
                tabURL = String.Empty;
                tabContent = String.Empty;
            }
     
            public TabedContentItem(string name, string value, string url, string content)
            {
                tabName = name;
                tabValue = value;
                tabURL = url;
                tabContent = content;
            }
        }

    in that class, tabContent variable contents HTML text from RadEditor control. If this HTML text is short then everything works great. But if it's long I have the next error
    Invalid postback or callback argument. Event validation is enabled using
    <pages enableEventValidation="true"/> in configuration or <%@ Page
    EnableEventValidation="true" %> in a page. For security purposes, this
    feature verifies that arguments to postback or callback events originate from
    the server control that originally rendered them. If the data is valid and
    expected, use the ClientScriptManager.RegisterForEventValidation method in
    order to register the postback or callback data for validation.

    It happens when I add the second item with long tabContent in List in the designer (i.e. Click "add" button).
    I've fixed that so:
    I use System.Web.Script.Serialization.JavaScriptSerializer.Serialize and Deserialize methods for tabContent variable. I'm not sure if it's the best way but It works yet :)
    Also I've tried to use HTMLEncode and HTMLDecode methods but I had the same error.

    Do you have any ideas?

    Thanks,

    Eugene

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Jun 2011
    Link to this post
    Hi Eugene ,

    You can try adding UpdatePanel to see if the issue will be fixed. The designer is RadWindow and it looks like that there is some interaction with the post backs in it.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
4 posts, 0 answered