Reputation: 109
I have problem that to read value <input type="date" id="mydate" runat=""server/>
it is not like to read similar textbox as like textbox1.text
.How can I get the value?
Upvotes: 1
Views: 2763
Reputation: 8271
As you didnt mentioned your Framework , i'm assuming your using framework 4 .
So for Framework 4 and above, allows you to specify the type attribute.
Please refer to the Feature 3
Feature 3
New syntax lets you define a TextBox control that is HTML5 compatible. For example, the following code defines a TextBox control that is HTML5 compatible:
<asp:TextBox runat="server" type="some-HTML5-type"/>
Update
if you are using Older version of Framework here is work around
In Aspx
<input type="text" ID="txt1" runat="server"/>
In .cs :
string date = Request.Form["txt1"];
Upvotes: 1
Reputation: 1
You can use Jquery to get the value of a datetime control
$('#mydate').val();
if you are using ajax calls, send the value by converting that to a date format and send as ISO string
var v = $('#mydate').val();
var dt = new Date(v);
var str = dt.toISOString();
Upvotes: 0
Reputation: 1210
You can get values of input type using Request.Form["Your Id of input type"]
DateTime dt = Request.Form["mydate"]
Upvotes: 0
Reputation: 7490
HTML
<input type="date" id="mydate" name="mydate" runat="server"/>
Code behind:
string date = Request.Form["mydate"];
Upvotes: 0