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

Forums / Developing with Sitefinity / Retrieve EventID in custum registration form

Retrieve EventID in custum registration form

4 posts, 0 answered
  1. Charu
    Charu avatar
    3 posts
    Registered:
    31 Jul 2010
    31 Jul 2010
    Link to this post
    I am using Sitefinity 3.7 SP3 community edition. I have a event module setup such that when the user is viewing the calendar view of events, and the user clicks on a specific event, the user is shown the details of that clicked event. I have also added a custom registration form on that event detail page, where I let the user enter their email address, etc and click on Register button. When the user registers, I simply send an email to events coordinator. The problem is that I cannot retrieve the eventID of the clicked event in my custom module (form). If I had the eventID, I could get the event name and include that in the email being sent. Right now, the cooridnator gets the email with registrations, but doesnt know who registered for which event.


    Thanks
    Charu
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    02 Aug 2010
    Link to this post
    Hi Charu,

    Thank you for using our services.

    If you have built your registration form on the Events View control you can easily get the ID by exposing another property to the control itself. For this you will have to create a class that inherits from EventsView and do something as in the bellow code snippet:
    using Telerik.Events.WebControls;
    using System.ComponentModel;
    using Telerik.Cms.Web.UI;
    using System.Web.UI.WebControls;
     
    /// <summary>
    /// Summary description for CustomEventsView
    /// </summary>
    public class CustomEventsView: EventsView
    {
        [WebEditor("Telerik.FileManager.UrlWebEditor, Telerik.FileManager"), Category("Appearance")]
        public override string ItemListTemplatePath
        {
            get
            {
                object obj = ViewState["ItemListTemplatePath"];
                if (obj != null)
                    return "~/PATHTOYOUREVENTSLISTTEMPLATE";
                return null;
            }
            set
            {
                ViewState["ItemListTemplatePath"] = value;
            }
        }
     
        [WebEditor("Telerik.FileManager.UrlWebEditor, Telerik.FileManager"), Category("Appearance")]
        public override string SingleItemTemplatePath
        {
            get
            {
                object obj = ViewState["SingleItemTemplatePath"];
                if (obj != null)
                    return "~/PATHTOYOURSINGLEEVENTSTEMPLATE";
                return null;
            }
            set
            {
                ViewState["SingleItemTemplatePath"] = value;
            }
        }
     
        protected override void SetItemMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem)
        {
            base.SetItemMetadata(itemContainer, contentItem);
            HiddenField eventID =(HiddenField)this.FindContentViewControl("EventID", itemContainer);
            if (eventID != null)
            {
                eventID.Value = contentItem.ID.ToString();
            }
        }
    }

    So you can just add an asp:HiddenField control with ID="EventID" in the control templates for your events view control and then just get the event's ID from the value of the hidden field.

    Greetings,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Charu
    Charu avatar
    3 posts
    Registered:
    31 Jul 2010
    03 Aug 2010
    Link to this post

    Hi Radoslav,

    Thanks for a quick reply. But still its not working for me.

    I had placed all that code in Sitefinity/ControlTemplates/Events/ContentViewSingleItem.ascx.cs and also placed a textbox (txt1) in Sitefinity/ControlTemplates/Events/ContentVersionView.ascx and tried to retrieve the value in textBox as below

    protected override void SetItemMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem)
        {
            base.SetItemMetadata(itemContainer, contentItem);
            HiddenField eventID = (HiddenField)this.FindContentViewControl("EventID", itemContainer);
            TextBox txt1 = (TextBox)this.FindContentViewControl("EventID", itemContainer);
            if (eventID != null)
            {
                eventID.Value = contentItem.ID.ToString();
            }
            if (txt1.Text != null)
            {
               txt1.Text = contentItem.ID.ToString();          
               
            }
        }

    But TextBox doesn't show on EventScheduleView.

    Here is a summary of how I have implemented Events:
    1. EventsView - Showing events in a calendar
    2. EventsScheduleView - Show only 1 event that the user clicked on from the calendar
    3. I added a custom user control for registration form
    4. I created a page for EventDetail - where I dragged and dropped EventsScheduleView and my custom control

    Not sure if this is the correct approach.
    My requirements are very simple. I want to show the events on the calendar view. When the user clicks on an event in the calendar, I want to show the event details with a registration form. On submission, I want to send an email to the coordinator with the event name and registrant's name, etc.
    Is it possible for you to guide me how to set this up correctly? I really appreciate it. 

    Thanks,
    Charu

  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    06 Aug 2010
    Link to this post
    Hi Charu,

    I am sorry but this is not the way to approach this. I should have been clearer on this. The class I have sent to you should be added to your ~/App_Code/ directory. Then you should add it to your Sitefintiy toolbox (change the web.config):
    <toolboxControls>
    ...   
    <add name="Custom Events View" section="Custom Controls" type="CustomEventsView, App_Code" description="" />
    </toolboxControls>


    What you need to do is to fix the paths to your templates in my code and add a HiddenField control in the ItemTemplate of the repeater in the template for the list items and a HiddenFieldControl in the control template for single items. Then you should use the custom control, not be built in one.

    Regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
4 posts, 0 answered