服务端 System.Web.UI.WebControls.Calendar cdate 日期选择组件需要在客户端脚本控制 此组件的可见与不可见,去值,赋值 !急 !
解决方案 »
- 月份财务报告的数据表的写法,怎么写最好,没思路
- 对于不会技术的老板什么办?
- 在配置文件下Web.config下有个警告:未声明“inheritInChildApplications”属性
- 关于超链接打开excel的问题
- 这句group的句子怎么写?
- 提供一些有用的东西![在线帮助文档和OutLook开发技术]
- 如何能够固定datagrid的列宽度?
- 如何获取sql2000数据库中binary字段的内容?急!急!急!
- 给积分了!asp.net 浏览器中没有输入”www “,怎么自动填充?
- 请教一个分行的问题?
- 关于GridView中限制文字个数,头一次做网站,急啊~~
- 问1个DATAGRID问题,100分,急!UP有分.
document.all("Panel1").visible=true;
function showOrHideCalendar()
{
var div=document.getElementById("calendarDiv");
if(div)
{
if(div.style.display='')
{
div.style.display='none';
}
else
{
div.style.display='';
}
}
}
var popUp; function OpenCalendar(idname, postBack)
{
popUp = window.open('Calendar.aspx?formname=' + document.forms[0].name +
'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack,
'popupcal',
'width = 265,height = 260,left= 250,top= 250');
}function SetDate(formName, id, newDate, postBack)
{
eval('var theform = document.' + formName + ';');
popUp.close();
theform.elements[id].value = newDate;
if (postBack)
__doPostBack(id,'');
}
<HTML>
<HEAD>
<title>Calendar</title>
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<link href="../styles.css" type="text/css" rel="stylesheet">
<script language="javascript">
function CloseWindow()
{
self.close();
}
</script>
</HEAD>
<body bgColor="#ffffff" leftMargin="5" topMargin="5">
<form id="Calendar" method="post" runat="server">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr bgColor="white">
<td colspan="2"><img src="images/spacer.gif" height="10" width="1"></td>
</tr>
<tr bgColor="white">
<td align="center" colSpan="2">
<asp:dropdownlist id="ddlMonth" runat="server" CssClass="standard-text" Height="22px" Width="90px"
AutoPostBack="True"></asp:dropdownlist>
<asp:dropdownlist id="ddlYear" runat="server" CssClass="standard-text" Height="22px" Width="60px"
AutoPostBack="True"></asp:dropdownlist>
<asp:calendar id="Cal" runat="server" BorderWidth="5px" ShowTitle="False" ShowNextPrevMonth="False"
BorderStyle="Solid" Font-Size="XX-Small" Font-Names="Arial" BorderColor="White" DayNameFormat="FirstTwoLetters"
ForeColor="#C0C0FF" FirstDayOfWeek="Monday" CssClass="standard-text">
<todaydaystyle Font-Bold="True" ForeColor="White" BackColor="#990000"></todaydaystyle>
<daystyle BorderWidth="2px" ForeColor="#666666" BorderStyle="Solid" BorderColor="White" BackColor="#EAEAEA"></daystyle>
<dayheaderstyle ForeColor="#649CBA"></dayheaderstyle>
<selecteddaystyle Font-Bold="True" ForeColor="#333333" BackColor="#FAAD50"></selecteddaystyle>
<weekenddaystyle ForeColor="White" BackColor="#BBBBBB"></weekenddaystyle>
<othermonthdaystyle ForeColor="#666666" BackColor="White"></othermonthdaystyle>
</asp:calendar>
</td>
</tr>
<tr>
<td align="center" colSpan="2">
Date Selected:
<asp:label id="lblDate" runat="server"></asp:label>
<input id="datechosen" type="hidden" name="datechosen" runat="server">
</td>
</tr>
<tr>
<td colspan="2"><img src="images/spacer.gif" height="10" width="1"></td>
</tr>
<tr>
<td align="right">
<asp:button id="OKButton" runat="server" Text="OK" Width="60px"></asp:button>
</td>
<td align="left">
<a href="javascript:CloseWindow()">
<asp:button id="CancelButton" runat="server" Text="Cancel" Width="60px"></asp:button>
</a>
</td>
</tr>
</table>
</form>
</body>
</HTML>
<div id="myControl">
...你的组件...
</div>要在客户端显示时:document.getElementById("myControl").style.display = "";
不要显示时:document.getElementById("myControl").style.display = "none";
//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 System.Configuration;namespace Webs.caseManage
{
/// <summary>
/// Calendar 的摘要说明。
/// </summary>
public class Calendar : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList ddlYear;
protected System.Web.UI.WebControls.Calendar Cal;
protected System.Web.UI.WebControls.Label lblDate;
protected System.Web.UI.WebControls.Button OKButton;
protected System.Web.UI.WebControls.Button CancelButton;
protected System.Web.UI.WebControls.DropDownList ddlMonth;
protected System.Web.UI.HtmlControls.HtmlInputHidden datechosen; private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
string selected = Request.QueryString["selected"];
string id = Request.QueryString["id"];
string form = Request.QueryString["formname"];
string postBack = Request.QueryString["postBack"];
Cal.FirstDayOfWeek = (System.Web.UI.WebControls.FirstDayOfWeek)1;//(System.Web.UI.WebControls.FirstDayOfWeek)Convert.ToInt32(ConfigurationSettings.AppSettings[Global.CfgKeyFirstDayOfWeek]);
try
{
Cal.SelectedDate = Cal.VisibleDate = Convert.ToDateTime(selected);
}
catch
{
Cal.SelectedDate = Cal.VisibleDate = DateTime.Today;
}
FillCalendarChoices();
SelectCorrectValues(); OKButton.Attributes.Add("onClick", "window.opener.SetDate('" + form + "','" + id + "', document.Calendar.datechosen.value," + postBack + ");");
CancelButton.Attributes.Add("onClick", "CloseWindow()");
}
} private void FillCalendarChoices()
{
DateTime thisdate = new DateTime(DateTime.Today.Year,1,1);
for (int x=0; x<12; x++)
{
ListItem li = new ListItem(thisdate.ToString("MMMM"), thisdate.Month.ToString());
ddlMonth.Items.Add(li);
thisdate = thisdate.AddMonths(1);
} for (int y=2000; y <= thisdate.Year + 5; y++)
{
ddlYear.Items.Add(y.ToString());
}
}
private void SelectCorrectValues()
{
lblDate.Text = Cal.SelectedDate.ToShortDateString();
datechosen.Value = lblDate.Text;
ddlMonth.SelectedIndex = ddlMonth.Items.IndexOf(ddlMonth.Items.FindByValue(Cal.SelectedDate.Month.ToString()));
ddlYear.SelectedIndex = ddlYear.Items.IndexOf(ddlYear.Items.FindByValue(Cal.SelectedDate.Year.ToString()));
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.ddlMonth.SelectedIndexChanged += new System.EventHandler(this.ddlMonth_SelectedIndexChanged);
this.ddlYear.SelectedIndexChanged += new System.EventHandler(this.ddlYear_SelectedIndexChanged);
this.Cal.SelectionChanged += new System.EventHandler(this.Cal_SelectionChanged);
this.OKButton.Click += new System.EventHandler(this.OKButton_Click);
this.ID = "Calendar";
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Cal_SelectionChanged(object sender, System.EventArgs e)
{
Cal.VisibleDate = Cal.SelectedDate;
SelectCorrectValues();
} private void ddlMonth_SelectedIndexChanged(object sender, System.EventArgs e)
{
Cal.SelectedDate = Cal.VisibleDate
= new DateTime(Convert.ToInt32(ddlYear.SelectedItem.Value),
Convert.ToInt32(ddlMonth.SelectedItem.Value), 1);;
SelectCorrectValues();
} private void ddlYear_SelectedIndexChanged(object sender, System.EventArgs e)
{
Cal.SelectedDate = Cal.VisibleDate
= new DateTime(Convert.ToInt32(ddlYear.SelectedItem.Value),
Convert.ToInt32(ddlMonth.SelectedItem.Value), 1);;
SelectCorrectValues();
} private void OKButton_Click(object sender, System.EventArgs e)
{
}
}
}