1

This is my aspx

<p>Date: <input type="text" id="datepicker" >
        <asp:Button id="BookingForDate" runat="server" OnClick="BookingForDate_Click" Text="Search"/> </p> 
    <table id="DateBookingTable" runat="server" style="visibility:hidden">
        <tr><th>ID</th><th>PlanTime</th></tr>
    </table>

on my code in c# I can't see datepicker

why?

note please that i can take all the controllers from id except this one.

I already tried restart the visual studio

1
  • 5
    try to add runat="server" to your input-tag Commented Mar 18, 2014 at 11:37

4 Answers 4

4

You have 2 options

add runat="server" to the input

<input type="text" id="datepicker" runat="server" />

or create an TextBox

<asp:TextBox runat="server" id="datepicker"></asp:TextBox>
Sign up to request clarification or add additional context in comments.

Comments

4

You should add

runat="server"

to your input. No you are using an html control and not an asp.net server side control. Hence you can't access the value of the textbox the way you want.

So try the following and then you will be able to access the value of your textbox:

<asp:TextBox id="datepicker" runat="server"/>

Then in your code behind class you can access the value of this textbox

datepicker.Text

Another approach, as I pointed initially, it would be the following:

<input type="text" id="datepicker" runat="server">

Comments

3

You forgot to add the runat-attribute to your input-tag. Try this:

<input type="text" id="datepicker" runat="server">

With that change, you should be able to access the element from code behind

See MSDN

2 Comments

just take a look at the comments of the question :-)
Absolutely no problem ;)
3

You have not given name to your control and also add runat="server"

<input type="text" id="datepicker" runat="server" name='datepicker' />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.