[英]How to assign property for BasicDatePicker in asp.net c#?
I want to assign property for BasicDateTimePicker 我想为BasicDateTimePicker分配属性
I tried but it's getting null value 我尝试过,但它得到的是空值
Code: 码:
.ascx .ascx
<%@ Register Assembly="BasicFrame.WebControls.BasicDatePicker" Namespace="BasicFrame.WebControls" TagPrefix="dp" %>
<dp:BasicDatePicker ID="BasicDatePicker4" runat="server"></dp:BasicDatePicker>
.ascx.cs .ascx.cs
Here I'm maintaing the values 在这里我保持价值观
protected void Page_Load(object sender, EventArgs e)
{
txtUser.Text = Request.Form[txtUser.UniqueID];
dropCountry.SelectedValue = Request.Form[dropCountry.UniqueID];
dropEntry.SelectedValue = Request.Form[dropEntry.UniqueID];
//Here I'm getting "Cannot implicitly conert type string to System.Date"
BasicDatePicker4.SelectedDate = Request.Form[BasicDatePicker4.UniqueID];
}
I tried to assign the property but it's not working 我尝试分配属性,但无法正常工作
public string ExpiryDate
{
get
{
return BasicDatePicker4.SelectedDate.ToString();
}
set
{
BasicDatePicker4.SelectedDate = DateTime.Today;
}
}
Any ideas? 有任何想法吗? Thanks in advance
提前致谢
You never assign something to ExpiryDate, the setter of the property will only be called when you call 您永远不会为ExpiryDate分配任何东西,该属性的设置器仅在您调用时被调用
ExpiryDate = DateTime.Today
also change your setter to use value instead of a hardcoded date, and change the Type of your property to DateTime as the picker only excepts a DateTime 还将您的设置器更改为使用值而不是硬编码的日期,并将属性的类型更改为DateTime作为选择器,只有DateTime除外
public DateTime ExpiryDate
{
get
{
return BasicDatePicker4.SelectedDate;
}
set
{
BasicDatePicker4.SelectedDate = value;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.