aspx日历控件 [英] aspx calendar control
问题描述
我正在用c#在asp.net中开发Web应用程序,其中我有
2个网络表单.
第一个网页与母版页连接.
第二个未与母版页连接
在两个网页中,我都将文本框作为日期
我正在使用aspx日历控件获取日期.
第二个网页运行正常,未与母版页连接.
但是首先,我遇到了问题,例如要从aspx压延机控件获取日期.
在这种情况下,日历显示在图像中,请单击,但是当我从日历中选择日期时,我无法在文本框中获取日期
我的aspx代码如下所示:
Hi,
I m developing web application in asp.net with c# in which i m having
2 web form.
First web page is connected with masterpage.
Second is not connected with master page
in both webpage i m taking textbox for date
i m using aspx calendar control for taking date it.
Second webpage is running fine, which is not connected with masterpage.
But in first i m getting problem ,for taking date from aspx calender control.
in this case calender is shown in image, click but when i select date from calender, i m not getting date in textbox
My aspx code is show below:
<script language="javascript">
function PopupPicker(ctl) {
var PopupWindow = null;
PopupWindow = window.open('DatePicker.aspx?ctl=' + ctl, 'zx', 'width=250,height=250');
PopupWindow.focus();
}
</script>
< asp:TextBox ID ="txtDate" runat ="server">< img src ="images/btnimg.jpg"
style ="margin-top:3px; width:30px; height:13px; cursor:hand;" alt ="
önclick="PopupPicker(''txtDate'')"/>
和datepicker.aspx代码如下所示
<asp:TextBox ID="txtDate" runat="server"><img src="images/btnimg.jpg"
style="margin-top:3px;width:30px;height:13px; cursor:hand;" alt=""
önclick="PopupPicker(''txtDate'')" />
and datepicker.aspx code is shown below
<script language="javascript">
function SetDate(dateValue, ctl) {
thisForm = window.opener.document.forms[0].elements[ctl].value = dateValue;
self.close();
}
</script>
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
string ctrl = Request.QueryString["ctl"];
HyperLink hpl = new HyperLink();
hpl.Text = ((LiteralControl)e.Cell.Controls[0]).Text;
hpl.NavigateUrl = "javascript:SetDate('" + e.Day.Date.ToShortDateString() + "','" + ctrl + "');";
e.Cell.Controls.Clear();
e.Cell.Controls.Add(hpl);
}
有人可以帮我吗
can anyone help me pls
推荐答案
吉特!
从我的理解.您的网页中有一个Calendar控件,并且要确保无论何时在日历控件中选择一个日期,该日期都会反映在同一页面的文本框中.
如果这是您的意思. ?
拖动文本框,按钮(显示单击时的日历)和日历控件.
关于日历的选择更改事件
受保护的void Calendar1_SelectionChanged(object sender,EventArgs e)
{
字符串测试= Calendar1.SelectedDate.ToShortDateString();
TextBox1.Text =测试;
}
Hi jeet !
From what I understood . You have a Calendar control in your webpage and you want to make sure that whenever a date is picked in the calendar control it is reflected in the textbox in the same page,
If this is what you meant. ?
Drag a textbox, button(to show the calendar on click) and calendar control.
On the selectionchanged event of the calendar
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
string test = Calendar1.SelectedDate.ToShortDateString();
TextBox1.Text = test;
}
这篇关于aspx日历控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!