"System.Web.UI.WebControls.TextBoxMode" does not contain a definition for "Date",

Error message: "System.Web.UI.WebControls.TextBoxMode" does not contain a definition for "Date"

code:

<asp:TextBox ID="lastDate" runat="server" autocomplete="off" TextMode="Date" ></asp:TextBox> <ajax:CalendarExtender ID="lastDate_CalendarExtender" runat="server" Enabled="True" TargetControlID="lastDate"> 
+6
source share
3 answers

I may be adding my 2 cents quite late, but I thought it might help some people in the future. As mentioned by Rob, with .Net 4.5 you can use TextMode="Date" for your asp:TextBox , but browser support may be limited, as this will cause the TextBox to become an HTML5 date type text box in the output of the page. Most modern browsers support HTML5 from the moment I write this.

However, if this is what you want, 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 likely due to the wrong version of the target environment.

Change the Target-Framework property in your Web.Config as follows to get rid of this error.

Web.Config> configuration> system.web> compilation

 <compilation debug="true" defaultLanguage="C#" targetFramework="4.5" /> 

Hope this helps

+12
source

Check MSDN link

The description says that the Textmode property of an asp text field can only be set to 3 parameters.

Password : this mode can be selected if you want to show the entry in the text field as a dot (password type).

Single Line : Use to save the text field as a single line field.

Multiline : Use to make the text field as a comment, i.e. have multiple lines ...

I think that all TextBoxMode values ​​worked with .net framework 4.0 or less, now these three values ​​are supported.

+3
source

Supported in .net 4.5, but browser support is partial

With ASP.net 4.5, you can use this property with many values, such as Date - see the documentation for TextBoxMode . However, as of September 2014, caniuse.com reports that only 50% of users will be able to use it correctly. If you know that the targeted browsers have support, then uninstall CalendarExtender and change your project to target .net 4.5.

There are problems publishing TextMode = 'Date' in VS2012

In addition, if you publish a set of pre-compilations, you need to check the box "Allow pre-compiled site" or it will be erroneous (at least in VS2012 - if I find a solution for this, I will update my answer).

Give up ASP.net components to do the job

However, you can use ASP.net CompareValidator together with CalendarExtender instead

 <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" /> 
+2
source

All Articles