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

Forums / General Discussions / Control Designers, applyChanges, and Saving Data

Control Designers, applyChanges, and Saving Data

4 posts, 0 answered
  1. Conrad Ehinger
    Conrad Ehinger avatar
    59 posts
    Registered:
    22 Sep 2009
    18 May 2011
    Link to this post
    Okay, so I have my Control View (not designer view), below:

    <%@ Control Language="C#" %>
    First Text Box:
    <asp:Literal ID="Content1" runat="server"></asp:Literal>
     
    Second Text Box:
    <asp:Literal ID="Content2" runat="server"></asp:Literal>

    My designer view:
    <%@ Control Language="C#" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <%@ Register Assembly="Telerik.Sitefinity" TagPrefix="sitefinity" Namespace="Telerik.Sitefinity.Publishing.Web.UI.Designers" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI"
        TagPrefix="sitefinity" %>
    <%@ Register Assembly="Telerik.Sitefinity" TagPrefix="sitefinity" Namespace="Telerik.Sitefinity.Modules.Libraries.Web.UI.Designers" %>
    <sitefinity:FormManager id="formManager" runat="server" />
    <asp:TextBox ID="Content1" runat="server"></asp:TextBox>
    <asp:TextBox ID="Content2" runat="server"></asp:TextBox>

    To my knowledge, I have to use the applyChanges event to populate my control data with the data from the designer view. In my .cs file for the control (not the designer):

    private string _content1 = "";
    public string Content1
    {
        get { return this._content1; }
        set { this._content1 = value; }
    }
     
    private string _content2 = "";
    public string Content2
    {
        get { return this._content2; }
        set { this._content2 = value; }
    }
     
    protected Literal FirstBox
    {
        get { return Container.GetControl<Literal>("Content1", true); }
    }
    protected Literal SecondBox
    {
        get { return Container.GetControl<Literal>("Content2", true); }
    }

    So currently, in my JS I set the strings Content1 and Content2 using get_controldata. This is fine. But then I also have to use the InitializeControls event to populate FirstBox and SecondBox with Control1 and Control2 respectively. Is there any way, from the applyChanges event, to automatically populate the Text property of FirstBox/SecondBox. An example of what I mean below:

    applyChanges: function () {
        this.get_controlData().FirstBox.Text = $(".content1").val();
        this.get_controlData().SecondBox.Text = $(".content1").val();
    },
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    19 May 2011
    Link to this post
    Hello Conrad,

    applyChanges is called when you click on the "Save" button of the designer. There are another method - refereshUI that you can use - forces the designer to refresh the UI from the cotnrol Data

    All the best,
    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. Conrad Ehinger
    Conrad Ehinger avatar
    59 posts
    Registered:
    22 Sep 2009
    22 May 2011
    Link to this post
    Ivan,

    Thanks for following up. Unfortunately - that wasn't the question I was looking to have answered.

    With applyChanges or refreshUI, I want to know if there is a way to directly access control properties (Literal.Text e.g.) instead of having to access a string property that is later assigned to the Literal.Text in my InitializeControls method.

    Does this make sense? Just trying to save some code

    Thanks again
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    25 May 2011
    Link to this post
    Hi Conrad Ehinger,

    Unfortunately using the approach from your question will not work. You have to pass down the changes to the properties backed by your private fields. The text boxes will not be available in the context of the control data javascript object.

    Kind regards,
    Radoslav Georgiev
    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
4 posts, 0 answered