More in this section

Forums / Developing with Sitefinity / Get Event URL?

Get Event URL?

2 posts, 1 answered
  1. Jay
    Jay avatar
    51 posts
    Registered:
    16 Jul 2008
    04 Oct 2009
    Link to this post
    I'm trying to do some customization of the events modules.  I'm writing a user control to access the event and display some information.  One of the things I'd like to display is a link to the actual event detail page but I can't quite figure out how.  I can get the event itself from it's GUID...

    Guid EventID = new Guid(Request.QueryString["id"]); 
     
    Telerik.Events.EventsManager eventsManager = new Telerik.Events.EventsManager("Events"); 
    Telerik.Events.IEvent selectedEvent; 
     
    selectedEvent = eventsManager.GetEvent(EventID); 
     
    I can then access various information about the event like this:

    endtime = (DateTime)selectedEvent.End; 
    title = (string)selectedEvent.EventTitle; 
    street = (string)selectedEvent.ContentItem.GetMetaData("Street").ToString() 

    However, getting the actual URL of the event seems to be trickier.

    selectedEvent.ContentItem.Url returns:
    /09-10-04/Test_Event

    The actual URL for my event is:
    http://www.mydomain.com/events/calendar/09-10-04/Test_Event.aspx?Events=EventItem

    I could re-create this URL manually but I'm curious if there's any easy way to get it using the API.  Any thoughts would be appreciated.
    Thanks

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    05 Oct 2009
    Link to this post
    Hello Jay,

    Thank you for using our services.

    You could use cnt.UrlWithExtension which will append the page extension - aspx. The default url format is defined in Sitefinity's web.config file (urlRewriteFormat="Publication_Date]/[Title].aspx").

     Generally you could not get the full url, because the application does not know where you can put the control. The easiest way is to build the url - for instance hardcoding the page where EventsView control is added. Then you can use String.Concat method. You can also take a look at the following blog post. Note that if you use this approach you could need to consider that all pages will be search which will result in the website performance on each request.


    I hope that this information will help you. If you have more questions, please feel free to contact us.


    All the best,
    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.
    Answered
2 posts, 1 answered