More in this section

Forums / Developing with Sitefinity / RadFileExplorer in FieldControl

RadFileExplorer in FieldControl

1 posts, 0 answered
  1. John
    John avatar
    9 posts
    03 Nov 2011
    08 Mar 2012
    Link to this post
    Hi all! I'm trying to create a custom module with a video uploader to my client's server for various formats (i.e. swf) that I don't want stored in the Document/Image libraries because I want to preserve the physical filename and I don't want to store it in the database (the flash player we're using needs a physical url to the file in .swf format, when using Sitefinity's filesystem storage instead of database storage the uploaded filename gets turned into a Guid with no extension), so I've derived a new FieldControl for my module video item creation. I'm having issues though on the module page with it trying to do a callback from my RadFileExplorer and coming back with an error that it can't find the target. I'm assuming the control is being added too late in the page's life cycle* and the control ID is lost in the process when the RadFileExplorer tries to do its postback. Any ideas on how I can get around this? (Error message is attached as image.)

    *i.e. I'm guessing that the module pages add in their respective CompositeControls during the rendering phase of the life cycle after postback event handling so it can't find the target ID for my control when the RadFileExplorer does the Ajax callback. I've tried as well overriding the OnInit and loading in the template for the control to the page but it throws an exception that I'm not allowed to do that during Init/DataBind/Load.

    From the definitions file:
    var field2 = new TextFieldDefinitionElement(mainSection.Fields)
        ID = "field2",
        DataFieldName = "VideoFile",
        DisplayMode = displayMode,
        Title = "Video File",
        CssClass = "sfTitleField",
        WrapperTag = HtmlTextWriterTag.Li,
        FieldType = typeof(UploadSWFControl)
    field2.ValidatorConfig = new ValidatorDefinitionElement(field2)
        Required = true,
        MessageCssClass = "sfError",
        RequiredViolationMessage = "Video File is required"

    (VideoFile is a string to the path on the server selected from the RadFileExplorer)

    My control file (I'm just including the highlights here):
    namespace VideoModule.Controls
        public class UploadSWFControl : FieldControl
            public UploadSWFControl()
                this.LayoutTemplatePath = "~/VideoTemplates/VideoModule.Controls.UploadSWFControl.ascx";
    protected internal virtual RadFileExplorer ExplorerControl
            return this.Container.GetControl<RadFileExplorer>("uploadSWFExplorer", true);
    public override IEnumerable<System.Web.UI.ScriptDescriptor> GetScriptDescriptors()
        List<ScriptDescriptor> list = new List<ScriptDescriptor>();
        ScriptControlDescriptor item = (ScriptControlDescriptor)base.GetScriptDescriptors().Last<ScriptDescriptor>();
        item.AddComponentProperty("uploadControl", this.ExplorerControl.ClientID);
        item.AddElementProperty("textControl", this.ValueTextBox.ClientID);
        return list;
    public override IEnumerable<System.Web.UI.ScriptReference> GetScriptReferences()
        string fullName = typeof(VideoItemControl).Assembly.FullName;
        List<ScriptReference> list = new List<ScriptReference>(base.GetScriptReferences())
            new ScriptReference("VideoModule.Controls.UploadSWFControl.js", fullName),
            new ScriptReference("Telerik.Sitefinity.Resources.Scripts.jquery-ui-1.8.8.custom.min.js", typeof(DateField).Assembly.FullName)
        return list.ToArray();

    (and so on...)

    My template file:
    <%@ Control Language="C#" %>
    <%@ Register Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" TagPrefix="sf" %>
    <%@ Register Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" TagPrefix="sf2" %>
    <%@ Register tagPrefix="sitefinity" namespace="Telerik.Sitefinity.Web.UI.Fields" assembly="Telerik.Sitefinity" %>
    <sitefinity:FormManager ID="formManagerSWF" runat="server" />
    <sf2:SitefinityLabel id="titleLabel" runat="server" WrapperTagName="div" HideIfNoText="false" CssClass="sfTxtLbl" AssoicatedControlID="valueTextBox" />
    <sf:RadFileExplorer ID="uploadSWFExplorer" runat="server" InitialPath="/" EnableCopy="false" EnableOpenFile="false" Width="520px" RegisterWithScriptManager="true" EnableViewState="false" >
        <Configuration ViewPaths="/" DeletePaths="/" UploadPaths="/" SearchPatterns="*.swf"  MaxUploadFileSize="100000000" />
    <asp:TextBox ID="valueTextBox" runat="server" style="width:520px; margin-top:10px; "></asp:TextBox>
1 posts, 0 answered