Adding Buttons in Rad Calender Cell

4 posts, 0 answers
  1. A2H
    A2H avatar
    177 posts
    Member since:
    Mar 2010

    Posted 07 Feb 2011 Link to this post

    Hi All,
    I am using Telerik Rad Calender

    1) I have to show two buttons in each calender cell.
    2) I have to capture the additional two butttons click event.
    how can i do this.

    Pls help me
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Feb 2011 Link to this post

    Hello,


    Add the buttons in Day Template of RadCalendar to show it for all dates.

    Here is the forum link which discussed similar scenario:
    How do I render a textbox in each day of the calendar


    -Shinu.
  3. A2H
    A2H avatar
    177 posts
    Member since:
    Mar 2010

    Posted 07 Feb 2011 Link to this post

    Hi Shinu,

    Thanks for your quick reply.

    I had gone through your examples ,But while implementing I found that its changing the default date display in calender.
    What i need I want the date also should be shown ,with that two buttons also need to add in calender.
  4. Radoslav
    Admin
    Radoslav avatar
    1566 posts

    Posted 10 Feb 2011 Link to this post

    Hello A2H,

    Please check out the following online documentation article.
    http://www.telerik.com/help/aspnet-ajax/calendar_howtoaddingtocalendarcell.html
    Additionally please note that handling the server side events of the dynamically added controls into the calendar cell is not a supported scenario. The controls could be added when the PreRender is fired, however attaching events on prerender  event is too late. However you could attach a client side function:
    void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
        {
            DateTime date = e.Day.Date;
            Label label = new Label();
            label.Text = e.Day.Date.Day.ToString();
            e.Cell.Controls.Add(label);
     
            Button button1 = new Button();
            button1.Text = "b1";
            button1.OnClientClick = string.Format("buttonClickHandler('{0}');", date);
            e.Cell.Controls.Add(button1);
     
            Button button2 = new Button();
            button2.Text = "b2";
            button2.OnClientClick = string.Format("buttonClickHandler('{0}');", date);
            e.Cell.Controls.Add(button2);
        }

    On this javascript function you could perform ajaxRequest and handle it on RadAjaxManager.AjaxRequest event:
    <telerik:RadCodeBlock runat="server">
        <script type="text/javascript">
            function buttonClickHandler(date)
            {
                var ajaxManager = $find("<%=RadAjaxManager1.ClientID %>");
                ajaxManager.ajaxRequest(date);
            }
        </script>
     
    </telerik:RadCodeBlock>

    void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
          var date = DateTime.Parse(e.Argument);
    }

    Additionally I am sending you a simple example. Please check it out and let me know if it helps you.

    Best wishes,
    Radoslav
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top