I am extending TextBox WebControl to work as a sort of "DateTextBox" which exposes it's value as a property (DateValue
) in the code-behind:
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();
}
}
}
Given the fact that this control is only supposed to be used with dates, there's no reason for it to inherrit the Text
property from it's parrent.
Is there any way to hide it?.. Other than implementing a NotImplementedException
, like so:
new public String Text
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}