Control Designers, applyChanges, and Saving Data

Posted by Community Admin on 03-Aug-2018 14:22

Control Designers, applyChanges, and Saving Data

All Replies

Posted by Community Admin on 18-May-2011 00:00
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();
,
Posted by Community Admin on 19-May-2011 00:00
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
Posted by Community Admin on 22-May-2011 00:00
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
Posted by Community Admin on 25-May-2011 00:00
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
This thread is closed