'System.Web.UI.WebControls.TextBoxMode' does not contain a definition for 'Date'
Supported in .net 4.5, but browser support is partial
With ASP.net 4.5 you can use this property with more values like Date - see the documentation for TextBoxMode. However, as of Sep 2014, caniuse.com reports only 50% of users will be able to use it properly. If you know the browsers you're targeting have support, then remove the CalendarExtender
and change your project to target .net 4.5.
There are issues publishing TextMode='Date' in VS2012
Additionally, if you're publishing with pre-compilation set, you need to have 'Allow precompiled site to be updatable' checked or it will error (at least in VS2012 - if I find a solution to this I'll update my answer).
Fall-back to ASP.net components to do this work
However, you can instead use the ASP.net CompareValidator
along with the CalendarExtender
<asp:TextBox ID="lastDate" runat="server" autocomplete="off" />
<ajax:CalendarExtender ID="lastDate_CalendarExtender" runat="server"
Enabled="True" TargetControlID="lastDate" />
<asp:CompareValidator ID="CompareValidator2" runat="server"
ControlToValidate="txtDateDiscIssued"
ErrorMessage="* invalid"
Operator="DataTypeCheck"
Type="Date" />
Check the following MSDN Link
The Description says Textmode property of asp text box can only be set to following 3 options.
Password
: This mode can be selected if you want to show the input in textbox as dot's (Password type).
Single Line
: Use to retain the textbox as single line field.
Multiline
: Use to make textbox as commentbox , i.e to have multiple lines...
I think all TextBoxMode
values worked with .net framework 4.0 or less, now these three values are supported.
Maybe I am quite late in adding my 2 cents but I thought this might help some people in future. As mentioned by Rob, since .Net 4.5 you can use TextMode="Date"
for your asp:TextBox
but the browser support might be limited as this will render your TextBox as HTML5 date type textbox in the page output. Most modern browsers do support HTML5 as of the time I am writing this.
However if this is what you desire, then there is no problem with your Markup.
<asp:TextBox ID="lastDate" runat="server" autocomplete="off" TextMode="Date" />
If you see this error message in Visual Studio Visual Studio it is most probably because of incorrect target framework version.
Change the Target-Framework property in your Web.Config as following to get rid of this error.
Web.Config > configuration > system.web > compilation
<compilation debug="true" defaultLanguage="C#" targetFramework="4.5" />
Hope this helps
Definitely not way to fix the error but you could avoid it by adding an html attribute type
instead of TextMode
.
type="date"