首页 > 编程 > .NET > 正文

asp.net下的日历控件源代码

2024-07-10 12:56:50
字体:
来源:转载
供稿:网友
前台aspx文件
<%@ register tagprefix="componentart" namespace="componentart.web.ui" assembly="componentart.web.ui" %>
<%@ page language="c#" codebehind="democalendar.aspx.cs" autoeventwireup="false" inherits="ordermrp.demo.calendar.democalendar" %>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" >
<html>
<head>
<title>日历控件</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<script>
var dropshow=false
var currentid
function dropdown(el){
if(dropshow){
dropfadeout()
}else{
currentid=el
el.style.visibility="visible"
dropfadein()
}
}
function dropfadein(){
if(currentid.filters.alpha.opacity<100){
currentid.filters.alpha.opacity+=20
fadetimer=settimeout("dropfadein()",50)
}else{
dropshow=true
cleartimeout(fadetimer)
}
document.all.ddl_text.innertext="";
}
function dropfadeout(){
if(currentid.filters.alpha.opacity>0){
cleartimeout(fadetimer)
currentid.filters.alpha.opacity-=20
fadetimer=settimeout("dropfadeout()",50)
}else{
dropshow=false
currentid.style.visibility="hidden"
}
}
function dropdownhide(){
if(dropshow){
dropfadeout()
dropshow=false
}
}

/*
function hilight(el)
{
if(dropshow)
{
for(i=0;i<el.parentelement.childnodes.length;i++)
{
el.parentelement.childnodes(i).classname="link_record0"
}
el.classname="link_record1"
}
}
//function checkme(el){
//document.all.ddl_text.innertext=el.innertext
//}
*/
document.onclick=dropdownhide
</script>
<link href="ddlcontrol.css" type="text/css" rel="stylesheet">
</head>
<body bgcolor="#e6e7ed" onload="document.all.form1.reset()">
<form id="form1" runat="server">
<table id="table20">
<tr>
<td>
<div class="link_box" onselectstart="return false" style="width: 100px">
<div class="link_head">
<table id="table30" height="100%" cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td>
<div class="link_text"><nobr><asp:textbox id="ddl_text" runat="server" width="97px" font-size="9pt" borderstyle="groove">---请选择---</asp:textbox><!--onkeyup="dropdown(value11)" onchange="window.alert('vv')"-->
<!--
<label id="ddl_text">---请选择---</label>
<input id="ddl_text" type="text" value="---请选择---" name="ddl_text">
--></nobr></div>
</td>
<td align="right" width="22"><img alt="" src=http://www.163design.net/n/a/"..images/other/bimg.gif" onload="this.style.cursor='hand'" onclick="dropdown(value11)"
onmouseup="this.classname='link_arrow0'" class="link_arrow0" onmousedown="this.classname='link_arrow1'" onmouseout="this.classname='link_arrow0'"
onmouseover="" height="20" width="16">
<!--
<div onmouseup="this.classname='link_arrow0'" class="link_arrow0" onmousedown="this.classname='link_arrow1'"
onmouseout="this.classname='link_arrow0'">6</div>
-->
</td>
</tr>
</table>
</div>
<div class="link_value" id="value11" style="width: 200px; height: 200px">
<table id="table40" cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
<tr>
<td align="center" bgcolor="#ffffff" height="30"><asp:calendar id="calendar1" runat="server" font-size="5pt" width="198px" backcolor="white" cellpadding="1"
forecolor="royalblue" borderwidth="1px" daynameformat="firstletter" height="198px" font-names="verdana" bordercolor="#d9d9e6" nextmonthtext="下月"
prevmonthtext="上月">
<todaydaystyle forecolor="white" backcolor="#99cccc"></todaydaystyle>
<selectorstyle forecolor="#336666" backcolor="#99cccc"></selectorstyle>
<nextprevstyle font-size="8pt" forecolor="snow"></nextprevstyle>
<dayheaderstyle height="1px" forecolor="#336666" backcolor="#99cccc"></dayheaderstyle>
<selecteddaystyle font-bold="true" forecolor="#ccff99" backcolor="#009999"></selecteddaystyle>
<titlestyle font-size="7pt" font-bold="true" height="25px" borderwidth="1px" forecolor="white"
borderstyle="solid" bordercolor="#d9d9e6" backcolor="#6699cc"></titlestyle>
<weekenddaystyle backcolor="#ccccff"></weekenddaystyle>
<othermonthdaystyle forecolor="#999999"></othermonthdaystyle>
</asp:calendar></td>
</tr>
</table>
</div>
</div>
</td>
<td><asp:imagebutton id="imagebutton1" runat="server" imageurl="~/images/loginimg/login_ok.gif"></asp:imagebutton></td>
</tr>
</table>
<p>&nbsp;</p>
<p><font face="宋体"></font>&nbsp;</p>
<p><font face="宋体"></font>&nbsp;</p>
<p><font face="宋体"></font>&nbsp;</p>
<p><font face="宋体"></font>&nbsp;</p>
<p><font face="宋体"></font>&nbsp;</p>
<p>&nbsp;</p>
</form>
</body>
</html>

后台cs文件
using system;
using system.collections;
using system.componentmodel;
using system.data;
using system.drawing;
using system.web;
using system.web.sessionstate;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.htmlcontrols;

using nicklee.web.ui;

namespace ordermrp.demo.calendar
{
/// <summary>
/// democalendar 的摘要说明。
/// </summary>
public class democalendar : system.web.ui.page
{
private nicklee.web.ui.encryption en1=new encryption();
private webdatafill fill=new webdatafill();

protected system.web.ui.webcontrols.imagebutton imagebutton1;
protected system.web.ui.webcontrols.textbox ddl_text;
protected system.web.ui.webcontrols.button button1;
protected system.web.ui.webcontrols.calendar calendar1;

private void page_load(object sender, system.eventargs e)
{
fill.constring=system.configuration.configurationsettings.appsettings["sqlconnectionstring"];

}

#region web form designer generated code
override protected void oninit(eventargs e)
{
//
// codegen:该调用是 asp.net web 窗体设计器所必需的。
//
initializecomponent();
base.oninit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void initializecomponent()
{
this.ddl_text.textchanged += new system.eventhandler(this.ddl_text_textchanged);
this.calendar1.visiblemonthchanged += new system.web.ui.webcontrols.monthchangedeventhandler(this.calendar1_visiblemonthchanged);
this.calendar1.selectionchanged += new system.eventhandler(this.calendar1_selectionchanged);
this.imagebutton1.click += new system.web.ui.imageclickeventhandler(this.imagebutton1_click);
this.load += new system.eventhandler(this.page_load);

}
#endregion

private void imagebutton1_click(object sender, system.web.ui.imageclickeventargs e)
{
if(ddl_text.text!="")
{
webjsutil.alert(this,ddl_text.text);
this.ddl_text.text="---请选择---";
// webjsutil.executeclientscriptonwindowload(this,"dropdown(value11)");
}
else
{
webjsutil.alert(this,"请选择或输入!");
}
}

private void calendar1_selectionchanged(object sender, system.eventargs e)
{
ddl_text.text=calendar1.selecteddate.toshortdatestring();
}

private void calendar1_visiblemonthchanged(object sender, system.web.ui.webcontrols.monthchangedeventargs e)
{
webjsutil.executeclientscriptonwindowload(this,"dropdown(value11)");
}

private void ddl_text_textchanged(object sender, system.eventargs e)
{
// webjsutil.alert(this,this.ddl_text.text);
}
}
}




  • 网站运营seo文章大全
  • 提供全面的站长运营经验及seo技术!
  • 发表评论 共有条评论
    用户名: 密码:
    验证码: 匿名发表