Problem in updating a field with customdesigner - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Problem in updating a field with customdesigner

  • Problem in updating a field with customdesigner
  • 261982_eror.png
    Hello Telerik,
    I'm tring to develop a custom designer for a simple user control I've done.

    The problem I got is that the setter of my Custom user control (not designer) is not updated (and I got a js exception when loading)

    Here're my classes (taking as example this link) :

    Custom UserControl (the part it's intresting) :

    private int _ProvaID = 5;
         public int ProvaID
         
             get
             
                 return _ProvaID;
             
             set
             
                 _ProvaID = value;
             
         

    The .js 

    Type.registerNamespace("SitefinityWebApp.Resources");
      
    SitefinityWebApp.Resources.FormattedDownloadList_Designer = function (element)
        SitefinityWebApp.Resources.FormattedDownloadList_Designer.initializeBase(this, [element]);
      
    SitefinityWebApp.Resources.FormattedDownloadList_Designer.prototype =
      
        initialize: function ()
            SitefinityWebApp.Resources.FormattedDownloadList_Designer.callBaseMethod(this, 'initialize');
        ,
        dispose: function ()
            SitefinityWebApp.Resources.FormattedDownloadList_Designer.callBaseMethod(this, 'dispose');
        ,
        refreshUI: function ()
            var data = this._propertyEditor().get_control();
            jQuery("#ProvaID").val(data.ProvaID);
        ,
      
        applyChanges: function ()
      
            var controlData = this._propertyEditor().get_control();
            controlData.ProvaID = jQuery("#ProvaID").val();
        

    The Designer .ascx :

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FormattedDownloadList_Designer.ascx.cs"
        Inherits="SitefinityWebApp.Resources.FormattedDownloadList_Designer" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI"
        TagPrefix="sitefinity" %>
    <%--<sitefinity:ResourceLinks ID="resourcesLinks" runat="server">
        <sitefinity:ResourceFile AssemblyInfo="SitefinityWebApp.Controls.FormattedDownloadList, SitefinityWebApp, Version=4.0.1210.0, Culture=neutral, PublicKeyToken=null"
            Static="true" />
    </sitefinity:ResourceLinks>--%>
    <div id="LibraryOption">
        <label for="ProvaID"> Width</label>
        <asp:TextBox runat="server" ID="ProvaID" Text=""></asp:TextBox>
    </div>

    and the Designer .cs

    public partial class FormattedDownloadList_Designer : ControlDesignerBase
        
            protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
            
                base.DesignerMode = ControlDesignerModes.Simple;
            
      
            protected override string LayoutTemplateName
            
                get
                
                    return "SitefinityWebApp.Resources.FormattedDownloadList_Designer.ascx";
                
            
      
            public override IEnumerable<System.Web.UI.ScriptReference> GetScriptReferences()
            
                var res = new List<ScriptReference>(base.GetScriptReferences());
                var assemblyName = this.GetType().Assembly.GetName().ToString();
                res.Add(new ScriptReference("SitefinityWebApp.Resources.FormattedDownloadList_Designer.js", assemblyName));
      
                return res.ToArray();
            
      
            public override IEnumerable<ScriptDescriptor> GetScriptDescriptors()
            
                //This is taken from the forum....I've got ProvaID null here
                ScriptControlDescriptor desc = new ScriptControlDescriptor(this.GetType().FullName, this.ClientID);
               // desc.AddElementProperty("ProvaID", this.ProvaID.ClientID);
                return new[] desc ;
            
        

    The exception I got (and if I click on ignore in VS2010 it loads) is the one I've attached below ... the ProvaID's getter of my user control is called but the value is not displayed

    What am I doing wrong? is there a way of understanding why I got this JS error?
    Thanks 
    Ilaria

     
  • Hello,
    I missed this piece of code :

    SitefinityWebApp.Resources.FormattedDownloadList_Designer.registerClass('SitefinityWebApp.Resources.FormattedDownloadList_Designer', Telerik.Sitefinity.Web.UI.ControlDesign.ControlDesignerBase);
    if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

    now it works... thanks