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

Forums / Developing with Sitefinity / Extending Events Module - Adding File Associations

Extending Events Module - Adding File Associations

7 posts, 0 answered
  1. Travis
    Travis avatar
    86 posts
    Registered:
    15 Oct 2008
    01 Oct 2009
    Link to this post
    Hello,

    I want to extend the existing Events module, to add support for one or more files to be associated with the event. I understand that I need to modify the base control (which I can get from the empty templates), but simply adding a radupload to that will not work, obviously, and I'm not totally sure how to go about capturing the files that are to be uploaded (once the save button is pressed). What course of action should I be taking in order to accomplish this task?

    Thanks
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    01 Oct 2009
    Link to this post
    Hi Travis,

    Thank you for using our services.

    You can take a look at the following forum post: Adding image to Blog module. The principle is similar for events. However you will use the following button selector for selecting associated document:
    <sf:ContentMetaFields ID="MetaFields" runat="server">  
    ...  
     <li class="selector">   
          <asp:Label ID="Label2" AssociatedControlID="Document" runat="server">   
          <asp:Literal ID="Label222" runat="server" Text="Document"></asp:Literal>   
          <em id="DocumentLabel" runat="server"></em></asp:Label>   
          <asp:TextBox ID="Document" Text="" runat="server" MaxLength="250"></asp:TextBox>   
           <sfLib:ButtonSelector WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ItemDialog.aspx"  
                AssociatedControls="Document" ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx"   
                runat="server" ButtonText="Select" />    
           <class="example">   
           <asp:Literal ID="Literal26" runat="server" Text="Select Document"></asp:Literal></p>   
    </li>  
    ...  
     </sf:ContentMetaFields>  
     

    This should do the trick. If you have more questions, please feel free to contact us.

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Travis
    Travis avatar
    86 posts
    Registered:
    15 Oct 2008
    01 Oct 2009
    Link to this post
    Thanks Radoslav.

    One other question, how can I handle multiple files? The number of files is arbitrary, and will likely change from event to event. Any thoughts on doing this by extending the existing module? I have this form saving properly, and one reference to a file is being stored, but ctrl+click on other files in the listing, doesn't quite work.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    01 Oct 2009
    Link to this post
    Hi Travis,

    You can create a custom complex WebEditor (similar to this one used in the Button Selector) which allows multiple selection. The idea is that you will return not only one item. You will return many items. Your selector should use a  property of type Dictionary<string, string> . You need will need a TypeConverter that implements methods for converting the string representation of Dictionary to Dictionary object and vice versa.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Travis
    Travis avatar
    86 posts
    Registered:
    15 Oct 2008
    02 Oct 2009
    Link to this post
    I've done some looking around, but, somethings not clicking with me when it comes to creating a custom WebEditor. Can you point me in the right direction? I've looked at Gabe Sumner's 3 part blog about creating them (starting here).

    I understand the concept behind them, but I am confused when it comes to:

    a: Binding the Value of them to a meta field
    b: Having multiples of them on a form, so that I can select multiple files.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    04 Oct 2009
    Link to this post
    Hi Travis,

    a: Binding the Value of them to a meta field

    You are not binding any value. You should bind the control you use in the WebEditor template.

    this.Grid.DataSource = manager.GetContent();  
    this.Grid.DataBind();  
     
    .... 
       .... 
     
    void Grid_ItemCommand(object source, GridCommandEventArgs e)  
            {  
                List<string> vals = new List<string>(this.Value);  
                vals.Add(new Guid(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString()));  
                this.Value = vals.ToArray();  
                this.ChildControlsCreated = false;  
            }  


    b: Having multiples of them on a form, so that I can select multiple files.

    You can use RadGrid. For more information please take a look at Selecting multiple rows (server-side)

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Travis
    Travis avatar
    86 posts
    Registered:
    15 Oct 2008
    05 Oct 2009
    Link to this post
    I figured out how to do this. I created a user control then put it on my form. In my user control, I get the current Event, get the data from my MetaField (by accessing the Event directly, retrieving it through the EventsManager) and convert my string that is stored to my metafield to a Dictionary<string,string>. I then parse that out into a datatable and bind that to my gridview. My custom control has the same ID as the name of my meta field (in this case "AttachedDocuments") and I have a Text property which retrieves the string representation of my Dictionary<string,string> (like was mentioned earlier, I had to write a method to convert the string to a dictionary and a dictionary to the string).


    Thanks for your help!
Register for webinar
7 posts, 0 answered