DateValue
TextBox WebControl を拡張して、コード ビハインドで値をプロパティ () として公開する一種の「DateTextBox」として機能させます。
public sealed class DateTextBox : TextBox
{
public DateTime ?DateValue
{
/* ToDateFromUserInterface() and ToUserInterfaceString() are both
extension methods */
get
{
return
(
String.IsNullOrEmpty(Text) ?
new DateTime?() :
Text.ToDateFromUserInterface()
);
}
set
{
if (value != null) Text = ((DateTime)value).ToUserInterfaceString();
}
}
}
このコントロールは日付でのみ使用されることになっているため、親からText
プロパティを継承する理由はありません。
それを非表示にする方法はありますか?.. a を実装する以外にNotImplementedException
、次のように:
new public String Text
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}