I have a asp:Calendar
in my web forms application. I want to call a method in partial class when user mouse over the Calendar. I can change back color of dates onmouseover
by adding below line in DayRender
event of calendar as below.
e.Cell.Attributes["onmouseover"] = "this.style.backgroundColor='pink';";
But how can i call method in partial class onmouseover
?
I have tried as below. but it does not work.
in my aspx page
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<script type="text/javascript">
function SelectDates() {
PageMethods.selectAvlDates();
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<asp:Calendar ID="Vehicle_Calendar" runat="server" BackColor="#4b6c9e"
Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="250px" NextPrevFormat="ShortMonth"
OnPreRender="Vehicle_Calendar_PreRender" Width="330px" OnSelectionChanged="Vehicle_Calendar_SelectionChanged"
CellSpacing="1" DayHeaderStyle-BackColor="#ffffff" OnDayRender="Vehicle_Calendar_DayRender">
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" Height="8pt" />
<DayStyle BackColor="#CCCCCC" />
<NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="White" />
<OtherMonthDayStyle ForeColor="#999999" />
<TitleStyle BackColor="#4b6c9e" Font-Bold="True" Font-Size="12pt" ForeColor="White"
Height="12pt" />
<SelectedDayStyle BackColor="#4b6c9e" ForeColor="White" />
<TodayDayStyle BackColor="#999999" ForeColor="White" />
</asp:Calendar>
<asp:Label ID="lblResult" runat="server"></asp:Label>
</asp:Content>
Code behind
protected void Vehicle_Calendar_DayRender(object sender, DayRenderEventArgs e)
{
e.Cell.Attributes["onmouseover"] = "SelectDates()"; // called java script function from here
}
[System.Web.Services.WebMethod]
public void selectAvlDates()
{
lblResult.Text = "mouse over";
}
But label doesn't print mouse over when i move over the calendar.
How can i do this ?
onmouseover
get dates and add them to aList<DateTime>
. – Bishan Jun 27 at 10:51