C# 如何使用Asp.net日历
我有一个关于我正在从事的项目的问题 这是一个日历,您可以在其中对特殊的日期/年份发表评论 我正在使用asp.net日历控件 以下是这个想法的图像: 以下是标记代码:C# 如何使用Asp.net日历,c#,asp.net,C#,Asp.net,我有一个关于我正在从事的项目的问题 这是一个日历,您可以在其中对特殊的日期/年份发表评论 我正在使用asp.net日历控件 以下是这个想法的图像: 以下是标记代码: <%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Calender.master" CodeFile="Calender.aspx.cs" Inherits="_Default" %> <asp:Content ID="Header
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Calender.master" CodeFile="Calender.aspx.cs" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<form id="Form1" runat="server">
<asp:ScriptManager ID="SM1" runat="server" />
<asp:UpdatePanel ID="UP1" runat="server">
<ContentTemplate>
<asp:Calendar ID="Calendar1" ShowGridLines="true" CellPadding="15" runat="server"
OnDayRender="Calendar1_DayRender" OnSelectionChanged="Calendar1_SelectionChanged ">
</asp:Calendar>
<br />
<asp:FormView ID="FormView1" runat="server" AllowPaging="true"
DataKeyNames="date" DataSourceID="todoSrc" DefaultMode="Edit">
<EditItemTemplate>
<asp:Label ID="lblTodo" runat="server" AssociatedControlID="txtTodo" Text="Afspraak:" />
<br />
<asp:TextBox ID="txtTodo" runat="server" TextMode="MultiLine" Columns="30" Rows="5"
Text="<%# Bind('todo') %>"></asp:TextBox>
<br /><br />
<asp:LinkButton ID="butUpdate" runat="server" Text="Update" CommandName="Update" />
</EditItemTemplate>
<InsertItemTemplate>
<asp:Label ID="lblTodo" runat="server" Text="Toevoegen:" AssociatedControlID="txtTodo" />
<br />
<asp:TextBox ID="txtTodo" runat="server" Text="<%# Bind('todo') %>" TextMode="MultiLine"
Columns="30" Rows="5" />
<br />
<asp:Button ID="butInsert" runat="server" Text="Add" CommandName="Insert" />
</InsertItemTemplate>
</asp:FormView>
<br />
<asp:Button ID="butAddNew" runat="server" Text="Toevoegen" OnClick="butAddNew_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<SelectParameters>
<asp:SqlDataSource ID="todoSrc" runat="server" ConnectionString="<%$ ConnectionStrings:Stefan %>"
DeleteCommand="DELETE Calender WHERE date=@date" InsertCommand="INSERT Calender (date,todo) VALUES (@date,@todo)"
SelectCommand="SELECT * FROM Calender WHERE date=@date" UpdateCommand="UPDATE Calender SET todo=@todo WHERE date=@date">
<SelectParameters>
<asp:ControlParameter Name="date" ControlID="Calendar1" PropertyName="SelectedDate" />
</SelectParameters>
<InsertParameters>
<asp:ControlParameter Name="date" ControlID="Calendar1" PropertyName="SelectedDate" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="calendarSrc" runat="server" ConnectionString="<%$ ConnectionStrings:Stefan %>"
SelectCommand="SELECT date FROM Calender"></asp:SqlDataSource>
</form>
</asp:Content>
是否希望文本直接位于目标日期的单元格中 使用必须添加文字控件的OnDayRender方法:
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (todo.FindRows(e.Day.Date).Length > 0)
e.Cell.BackColor = System.Drawing.Color.Aqua;
if (e.Day.Date.Day == 18)
e.Cell.Controls.Add(new LiteralControl("<br />Test to show on the calendar."));
}
受保护的无效日历1\u DayRender(对象发送方,DayRenderReventArgs e)
{
如果(todo.FindRows(e.Day.Date).Length>0)
e、 Cell.BackColor=System.Drawing.Color.Aqua;
如果(e.Day.Date.Day==18)
e、 Cell.Controls.Add(新的LiteralControl(“
要在日历上显示的测试”);
}
祝你好运
Patrick是否希望文本直接位于目标日期的单元格中 使用必须添加文字控件的OnDayRender方法:
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (todo.FindRows(e.Day.Date).Length > 0)
e.Cell.BackColor = System.Drawing.Color.Aqua;
if (e.Day.Date.Day == 18)
e.Cell.Controls.Add(new LiteralControl("<br />Test to show on the calendar."));
}
受保护的无效日历1\u DayRender(对象发送方,DayRenderReventArgs e)
{
如果(todo.FindRows(e.Day.Date).Length>0)
e、 Cell.BackColor=System.Drawing.Color.Aqua;
如果(e.Day.Date.Day==18)
e、 Cell.Controls.Add(新的LiteralControl(“
要在日历上显示的测试”);
}
祝你好运
Patrick我的问题是我如何才能像图片中描述的那样去做我的问题是我如何才能像图片中描述的那样去做