在ASP.NET中实现弹出日历__教程 |
|
日期:2007-5-20 1:22:58 人气:66 [大 中 小] |
|
|
|
ctlCalendar.ascx的源代码:
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="ctlCalendar.ascx.cs" Inherits="calendar.ctlCalendar" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" enableViewState="True"%> <asp:textbox id="TextBox1" runat="server"></asp:textbox> <input type="button" id="Button1" runat="server" value="..."><br> <asp:Panel id="pnlCalendar" runat="server" style="POSITION: absolute"> <asp:calendar id="Calendar1" runat="server" FirstDayOfWeek="Monday" ShowGridLines="True" BackColor="White" DayNameFormat="Full" ForeColor="Black" Font-Size="8pt" Font-Names="Verdana" BorderColor="#999999" CellPadding="4" Width="200px" Height="180px"> <TodayDayStyle ForeColor="Black" BackColor="#CCCCCC"></TodayDayStyle> <SelectorStyle BackColor="#CCCCCC"></SelectorStyle> <DayStyle Wrap="False" BorderStyle="Dashed"></DayStyle> <NextPrevStyle VerticalAlign="Bottom"></NextPrevStyle> <DayHeaderStyle Font-Size="X-Small" Font-Names="宋体" Wrap="False" BorderStyle="Dashed" BackColor="#CCCCCC"></DayHeaderStyle> <SelectedDayStyle Font-Bold="True" ForeColor="White" BackColor="#666666"></SelectedDayStyle> <TitleStyle Font-Size="Small" Font-Bold="True" BorderStyle="Solid" BorderColor="Black" BackColor="#999999"></TitleStyle> <WeekendDayStyle BackColor="LightSteelBlue"></WeekendDayStyle> <OtherMonthDayStyle ForeColor="Gray"></OtherMonthDayStyle> </asp:calendar> </asp:Panel>
ctlCalendar.ascx.cs的源代码:
namespace calendar { using System; using System.Data; using System.Drawing; using System.Web; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls;
/// <summary> /// ctlCalendar 的摘要说明。 /// </summary> public class ctlCalendar : System.Web.UI.UserControl { protected System.Web.UI.WebControls.TextBox TextBox1; protected System.Web.UI.WebControls.Panel pnlCalendar; protected System.Web.UI.HtmlControls.HtmlInputButton Button1; protected System.Web.UI.WebControls.Calendar Calendar1;
private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { this.TextBox1.Text = System.DateTime.Now.ToShortDateString(); this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION: absolute"); } else { string id = Page.Request.Form["__EVENTTARGET"].Substring(0,Page.Request.Form["__EVENTTARGET"].IndexOf(":")); if (id != this.ID) { this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION: absolute"); } else { this.pnlCalendar.Attributes.Add("style","POSITION: absolute"); }
}
Page.RegisterClientScriptBlock("Script_Panel" + this.ID, "<script> function On"+this.ID+"Click() { if("+this.ID+ |
|
出处:本站原创 作者:佚名 |
|
|