Control designer with ascx template requires javascript file to work?
Hello,
Hi Robert,
Could you show the control and the script you use for your custom control designer?
All the best,
Ivan Dimitrov
the Telerik team
Hi Ivan,
[RequireScriptManager] [ControlDesigner(typeof(RotatorDesigner)), PropertyEditorTitle(typeof(Labels), "Change")] public class Rotator : SimpleView #region Fields private Unit width = new Unit(100, UnitType.Pixel); private Unit height = new Unit(50, UnitType.Pixel); private Color textColor = Color.White; private Guid albumGuid = Guid.Empty; [Browsable(true)] public Unit Width get return this.width; set this.width = value; [Browsable(true)] public Unit Height get return this.height; set this.height = value; [Browsable(true)] public Color TextColor get return this.textColor; set this.textColor = value; [Browsable(true)] public Guid AlbumGuid get return this.albumGuid; set this.albumGuid = value; #endregion #region Controls protected virtual RadRotator RotatorCtrl get return this.Container.GetControl<RadRotator>("rotator1", true); #endregion protected override void InitializeControls(GenericContainer container) this.RotatorCtrl.Width = Width; this.RotatorCtrl.Height = Height; if (AlbumGuid.Equals(Guid.Empty) == false) LibrariesManager man = new LibrariesManager(); var album = man.GetAlbums().Where(a => a.Id.Equals(AlbumGuid)).SingleOrDefault(); if (album != null) this.RotatorCtrl.ItemTemplate = new RotatorTemplate(this); this.RotatorCtrl.OnClientItemShowing = "rotatorItemShowing"; this.RotatorCtrl.OnClientItemShown = "rotatorItemShown"; this.RotatorCtrl.ItemHeight = new Unit(this.Height.Value, UnitType.Pixel); this.RotatorCtrl.ItemWidth = new Unit(this.Width.Value, UnitType.Pixel); this.RotatorCtrl.RotatorType = RotatorType.SlideShow; this.RotatorCtrl.SlideShowAnimation.Type = Telerik.Web.UI.Rotator.AnimationType.Fade; this.RotatorCtrl.PauseOnMouseOver = false; this.RotatorCtrl.DataSource = from i in album.Images select new i.MediaUrl, Text = i.AlternativeText ; this.RotatorCtrl.DataBind(); else Label lab = new Label(); lab.Text = "No Album selected."; this.Container.Controls.Add(lab); protected override void OnPreRender(EventArgs e) //register client stuff this.Page.ClientScript.RegisterClientScriptResource(this.GetType(), "ITOne.Sitefinity.Controls.Rotator.Resources.Rotator.css"); this.Page.ClientScript.RegisterClientScriptResource(this.GetType(), "ITOne.Sitefinity.Controls.Rotator.Resources.Rotator.js"); base.OnPreRender(e); protected override Type ResourcesAssemblyInfo get return this.GetType(); protected override string LayoutTemplateName get return "ITOne.Sitefinity.Controls.Rotator.Resources.Rotator.ascx"; public class RotatorDesigner : ControlDesignerBase #region Controls protected virtual RadComboBox Combo get return this.Container.GetControl<RadComboBox>("combo1", true); #endregion protected override void InitializeControls(GenericContainer container) this.DesignerMode = ControlDesignerModes.Simple; //populate combo with libraries/* using (var facade = App.WorkWith()) var libs = facade.Documents().Get(); this.Combo.DataTextField = "Title"; this.Combo.DataValueField = "Id"; this.Combo.DataSource = libs; this.Combo.DataBind(); */ LibrariesManager man = new LibrariesManager(); this.Combo.DataSource = man.GetAlbums(); this.Combo.DataTextField = "Title"; this.Combo.DataValueField = "Id"; this.Combo.DataBind(); protected override string LayoutTemplateName get return "ITOne.Sitefinity.Controls.Rotator.Designers.Resources.RotatorDesigner.ascx"; protected override Type ResourcesAssemblyInfo get return this.GetType(); /* 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("ITOne.Sitefinity.Controls.Rotator.Designers.Resources.RotatorDesigner.js", assemblyName)); return res.ToArray(); */
If I uncomment the block above, it works fine, otherwise it doesn't. Since the designer is javascript based I guess javascript file with proper namespace is mandatory?
Thanks,RobertHi Robert,
The control designer of the control cannot work properly as we have already discussed this in this post.
Best wishes,
Ivan Dimitrov
the Telerik team