This is a migrated thread and some comments may be shown as answers.

Adding Buttons in Rad Calender Cell

3 Answers 107 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
A2H
Top achievements
Rank 1
A2H asked on 07 Feb 2011, 10:49 AM
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

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Feb 2011, 11:22 AM
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.
0
A2H
Top achievements
Rank 1
answered on 07 Feb 2011, 12:27 PM
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.
0
Radoslav
Telerik team
answered on 10 Feb 2011, 12:51 PM
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.
Tags
Calendar
Asked by
A2H
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
A2H
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or