ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
1,173 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Can i select the date by clicking the cell of the date instead of the date character? Thanks.
Yes, you can add a "click" event to the cell.
so, assuming this markup for the calendar:
<asp:Calendar ID="Calendar1" runat="server" Height="751px" Width="1200px"
BorderColor="Black"
BorderStyle="Solid" BorderWidth="2px">
<DayHeaderStyle Height="40px" />
<DayStyle BorderStyle="Solid"
BorderColor="Black"
BorderWidth="1"
HorizontalAlign="Right"
VerticalAlign="Top" Height="80px" />
<OtherMonthDayStyle BackColor="LightSteelBlue" />
<SelectorStyle CssClass="btn-info" />
<TitleStyle Height="40px" />
<TodayDayStyle BackColor="LightSkyBlue" />
<WeekendDayStyle BackColor="Ivory" Height="60px" />
</asp:Calendar>
So, now in the day render event, you add this:
Protected Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs) Handles Calendar1.DayRender
If e.Day.IsSelected Then
e.Cell.BackColor = System.Drawing.Color.LightCoral
End If
e.Cell.Attributes.Add("OnClick", e.SelectUrl)
End Sub
And the day click event (date change), is this:
Protected Sub Calendar1_SelectionChanged(sender As Object, e As EventArgs) Handles Calendar1.SelectionChanged
' day sel
Debug.Print(Calendar1.SelectedDate)
End Sub
And now the result is this:
fantastic!
Merry Christmas!
Thanks a lot for your help