- 热门文章:
- · 在DataGrids和DropDownLists中使用ADO
- · asp.net 页面中生成 RSS 2.0 提要
- · Session登陆后丢失的解决办法
- · 基于HTTP协议用WinSock实现任意文件下载
- · 奔腾Flash Player source code
- · 《Essential .Net》读书笔记 - Chapter 2
- · 《Essential .Net》读书笔记 - Chapter 1
- · 获取指定IP的终端的MAC地址
- · 网络传输(FTP)问题
- · Paint.NET: An Open Source GDI+ App Likes Photoshop
- · 看到有人用 WebClient来下载, 发篇用 WebRequest 实现有进度下载的吧.
- · 树形控件TreeView的序列化
上一篇:一个拷贝整个文件夹(包括子文件夹)的方法(原创) >>
在ASP.NET中实现弹出日历
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+
"_pnlCalendar.style.display == \"none\") "+this.ID+
"_pnlCalendar.style.display = \"\"; else "+this.ID+
"_pnlCalendar.style.display = \"none\"; } </script>");
this.Button1.Attributes.Add("OnClick","On"+this.ID+"Click()");
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Calendar1.SelectionChanged += new System.EventHandler(this.Calendar1_SelectionChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
#region 日历选择时的事件
private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
{
this.TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION: absolute");
}
#endregion
}
}
相关文章:
- · 使用javascript+XML实现分页
- · 使用Control.Invoke处理多线程应用程序界面
- · WEB页面TreeView的应用-(得到所有选中的节点)
- · DotNetNuke(DNN)
- · 枚举器模式(Enumerator pattern)
- · 用ASP.NET 1.1 新特征防止Script攻击
- · 关于ASP.Net中的时间处理
- · javascript实现的数据表格:冻结列、调整列宽和客户端排序
- · [常见问题]cookie使用1.Page与HttpContext的Request、Response
- · 怎样在页面和页面的用户控件进行交互
- · webform页面间传值的特殊方法
- · 怎么直接建立一个DataTable并且为之添加数据
- · 我的第一个Asp.Net程序
- · 如何把数据放到web不能访问的文件夹中并给用户下载?
- · How to handle the concurrency problems on ASP.Net Database
- · 后台动态设置前台标签内容和属性
- · ASP.NET中让同一个页面不同的文本框回车响应不同的事件
- · 认识ASP.NET配置文件Web.config
- · 将ArrayList中的ListItem绑定到DropDownList中去
- · 安全存放web项目数据库连接字符串
- · 分享:Project级别的权限控制
- · Solidworks二次开发—06—在装配体中添加配合
- · 在Repeater中嵌套使用Repeater
- · 一个简单的加密/解密方法
- · 加入身份验证信息的SMTP mail发送
- · webconfig的设置节点说明
- · 现有的Web打印控制技术分成几种方案
- · 一段实现DataGrid的“编辑”、“取消”功能脚本[无刷新]
- · WEB图片高清晰浏览同打印
- · Tangram与软件的组合构造
- · solidworks二次开发-04-修改数据
- · Solidworks二次开发-05-装配体中插入零部件
- · solidworks二次开发-03-访问特征数据
- · solidworks二次开发-02-用来访问特征的两个API
- · solidworks二次开发-01-录制一个宏
- · 有关于web播放器的列表播放问题
- · Microsoft User Interface Process Application Block 研究(3)
- · ASP.NET中使用IFRAME建立类Modal窗口
