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

Forums / Developing with Sitefinity / Extending event controls

Extending event controls

7 posts, 1 answered
  1. Simon
    Simon avatar
    14 posts
    Registered:
    26 Jul 2008
    18 Oct 2009
    Link to this post
    I'm trying to extend the event controls but I'm missing something. After finding about the embedded templates I can now extend the templates to include the controls I want however, what I know need is the ability is to add a control that allows a user to register.

    What I need ( I think) is to embed in the normal event controls a link/button etc that I can user to fire my register/unregister code. But for this I need to be able to pass some identifier for the event. However I don't know how I can pass such an identifier to my usercontrol. The only way I can find of passing a value to a control is to have the control's ID the same as the meta property.

    So how can I get the identifier of the event to my user control.

    Cheers
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 Oct 2009
    Link to this post
    Hi Simon,

    You can create a custom class that derives from EventsView control. In your control template include the link that should fire unsubscrube/subscribe logic. Then override SetItemMetadata method where you have access to each IContent object and make reference to the unsubscrube/subscribe. By doing so you will associate the content item ID with your link. You can assing command argument and command name on a particular content item as well.

    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.
  3. Simon
    Simon avatar
    14 posts
    Registered:
    26 Jul 2008
    19 Oct 2009
    Link to this post
    Is there an example I can easily copy.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 Oct 2009
    Link to this post
    Hi Simon,

    Below is a sample code that you can use. From SetItemMetadata you can get access to contentItem object and its properties

    class EventsViewCustomcontrol : EventsView
    {
         
     
     
        public override string ItemListTemplatePath
        {
            get { return "~/Sitefinity/ControlTemplates/Events/ListPageMaster.ascx"; }
        }
     
        public override string SingleItemTemplatePath
        {
            get { return "~/Sitefinity/ControlTemplates/Events/ListPageDetails.ascx"; }
        }
     
     
        //override SetItemMetadata method.
        protected override void SetItemMetadata(System.Web.UI.Control itemContainer, IContent contentItem)
        {
            base.SetItemMetadata(itemContainer, contentItem);
            // HERE ACCESS YOUR HYPERLINK FROM THE TEMPLATE
            // HyperLink link = (HyperLink)itemContainer.FindControl("Link1");
            // HyperLink link = (HyperLink)itemContainer.Controls[0].FindControl("Link1");
              
     
        }
     
        
    }

    Sincerely yours,
    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. Simon
    Simon avatar
    14 posts
    Registered:
    26 Jul 2008
    19 Oct 2009
    Link to this post
    Ok so where do I put this.

    I've tried putting it in a .cs file in my site project.

    I added it to the toolbox with the following

     

    <add name="EventViewCS" section="Events" url="~/Sitefinity/UserControls/CustomContentView.cs" description="Event View 3" /> 


    <!---->

     

     

    but when I drag the control on to a page I get a "Object reference not set to an instance of an object." error message.

    I also tried adding it to a seperate dll but I got errors with that as well.

    What am I missing?

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 Oct 2009
    Link to this post
    Hello Simon,

    "You can create a custom class that derives from EventsView control" This is a custom control. You can add it to App_Code or compile it as an assemble.

    The control should be registered by type as shown below:

    <add name="EventsViewCustomcontrol" section="Custom" type="EventsViewCustomcontrol, App_Code"/>

    If you compile the control you should add the namspace as type.

    All the best,
    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.
    Answered
  7. Simon
    Simon avatar
    14 posts
    Registered:
    26 Jul 2008
    19 Oct 2009
    Link to this post
    Ok both those options worked.

    When I tried to use an external dll I tried to upload using the admin site but got caught out by error Gabe reported http://www.sitefinity.com/support/forums/sitefinity-3-x/set-up-installation/164952-failed-to-map-the-path.aspx. By running Visual studio as admin that route worked.

    And then the other option of moving the class file to app_code and using app_code in the type declaration worked.

    I dont know why referring to the cs file using the src property didn't work. Ah well, I'm now good to go.
Register for webinar
7 posts, 1 answered