RadCalendar and URL

4 posts, 0 answers
  1. Peter Zolja
    Peter Zolja avatar
    119 posts
    Member since:
    Dec 2007

    Posted 19 Sep 2008 Link to this post

    Hi,

    Is it possible to use the url to navigate a calendar? I could allow it to post-back and then redirect to mypage.aspx?date=1/9/08, but can I achieve something similar without the extra post-back?

    Another approach would be to put the RadCalendar inside an UpdatePanel and right before the postback change the URL dynamically with Javascript. Has anybody attempted to do this?

    Thanks.
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 22 Sep 2008 Link to this post

    Hello Peter,

    You can do this using DayRender server-side event:

        protected void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
        {
            e.Cell.Text = String.Format(@"<a href=""MyPage.aspx?Date={0}"">{1}</a>", e.Day.Date.ToString(), e.Day.Date.ToString());
        }


    Kind regards,
    Vlad
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Peter Zolja
    Peter Zolja avatar
    119 posts
    Member since:
    Dec 2007

    Posted 22 Sep 2008 Link to this post

    Sorry, I should have been more specific. I'm trying to change the next / previous month links. I'm already customizing the content of each cell. I'm trying to do this so that search engines could follow the calendar.

    Thanks.
  4. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 25 Sep 2008 Link to this post

    Hello Peter,

    One option is to use Js to locate the link(s) and alter the href, as shown in the code snippet below:

    .aspx
    <telerik:RadCalendar runat="server" Id="Calendar1" > 
    <ClientEvents OnLoad="onLoad" /> 
    </telerik:RadCalendar> 

    .Js
    <script type="text/javascript">      
                         
                   function onLoad()  
                   {  
                   var link = $get("Calendar1_NN");                 
                   link.href="newUrl";                 
                   }  
               
    </script> 

    I hope this suggestion helps.

    Kind regards,
    Yavor
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top