0

I want to get the value of my input tag into my C#.

     <div id="datetimepicker2" class="input-append">
            <input data-format="MM/dd/yyyy HH:mm:ss PP" type="text"></input>
            <span class="add-on">
              <i data-time-icon="icon-time" data-date-icon="icon-calendar">
              </i>
            </span>
    </div>// what should we use here?

The value is set by the user of the page.

Cullub
  • 2,901
  • 3
  • 30
  • 47
RookieRoll
  • 175
  • 1
  • 1
  • 16

4 Answers4

7

I did't understand which control value you want to get. But If you want to get input element value into the code behind, you need to set runat="server" attribute, because this is a simple html element not a Asp control.

Add runat="server" and id="your_id" and you should have access to them.

for example:

<input type="text" value="Username" class="input-text autoclear" 
   runat="server" id="myTextBox" />

than you can simply get value of input box like this:

string myStringFromTheInput = myTextBox.Value;

For more options please See here

Community
  • 1
  • 1
Ishan Jain
  • 8,063
  • 9
  • 48
  • 75
3

Try this

Add name for your input type

 <input data-format="MM/dd/yyyy HH:mm:ss PP" name="txtBox1" type="text"></input>

and try this way for get value in codebehind

string value=Request.Form["txtBox1"];
Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234
0

You can access all your submitted form data at server side by looking into the form Request object.

Ex. Request.Form["txtDate"] OR Request["txtDate"].

Naming the html elements makes easier to look into form collection for specified element.

Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234
-2

If what you posted is your actual code, you have an extra space in your closing tag

</asp: TextBox>

Should be

</asp:TextBox>

and then txt_todata.text should work