I have a calendar in my MasterPage, but I need to use this date to bind a datagrid in a ContentPage.
MasterPage html:
<asp:Calendar ID="calAgenda" DefaultView="Days" Format="dd/MM/yyyy" runat="server" BackColor="White" CssClass="templeteCalendar" Visible="false" OnSelectionChanged="calAgenda_SelectionChanged"></asp:Calendar>
ContentPage html:
<asp:TextBox runat="server" ID="txtFechaBusqueda" CssClass="form-control templeteLabel" MaxLength="10" />
MasterPage C# Code:
protected void calAgenda_SelectionChanged(object sender, EventArgs e)
{
TextBox txtCalendarDate = (TextBox)ContentPlaceHolder1.FindControl("txtFechaBusqueda");
txtCalendarDate.Text = calAgenda.SelectedDate.ToString().Substring(0, 10);
}
Here We have use a EventHandler in the ContentPage to catch the event click in the MaserPage.
ContentPage C# Code:
Calendar btnCalendar = Master.FindControl("calAgenda") as Calendar;
btnCalendar.SelectionChanged += new EventHandler(btnCalendar_Click);
Then We need to define the btnCalendar_Click function.
protected void btnCalendar_Click(object sender, EventArgs e)
{
DoSomething();
}