To pass Html Input value as ASP:textbox value in code behind (.cs page)

Posted by Anishabathija under ASP.NET on 11/16/2012 | Points: 10 | Views : 8780 | Status : [Member] | Replies : 4
hey ,

I have created a datetime picker using javascript , however the field to select the date is of the type html input. how Do I pass this value as a textbox value in my code behind page.

Please help.
thanks




Responses

Posted by: Funda on: 11/16/2012 [Member] Starter | Points: 25

Up
0
Down
I am not sure about your question.....
If you want a Html Input value in server side , use runat attribute [runat="server"] ...
example
<input id="Text1" runat="server" type="text" />

now you will be getting the Text1 in server side...


Anishabathija, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Anishabathija on: 11/16/2012 [Member] Starter | Points: 25

Up
0
Down
Yeah that's exactly what I have done.
Now I want to pass the value of this "<input>" field to my code behind (.cs page) .
how do I do that?

Anishabathija, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Deepraj on: 11/16/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
In order to access html tags in code behind use

[id of html tag].Value; 


which gives you value in code behind.

The HTML5 introduces new set of tags
<input type="date" id="mycal" runat="server" > is one new element

you can access this element using mycal.Value



Anishabathija, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Funda on: 11/16/2012 [Member] Starter | Points: 25

Up
0
Down
@Anishabathija
what Deepraj is correct....which is recommended always..you need to get value....
Still.....
As I dont know what you doing in the code ..so u can try the following...

Request.Form["elementId"]
HtmlElementCollection elems = document.GetElementsByTagName(elementName);
mytag.Attributes["NameOfElementAttribute"]

Still many ways are there....:-)






Anishabathija, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response