1

I have this control in ASP:

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

There's a JQuery function related to it

I want to get the value in the input text in my VB code, so I used this

 Dim VALUE As String
 VALUE = Request.Form("datepicker")

But it's not working.

I am getting VALUE is nothing

What am I doing wrong?

4
  • If your VB code show above is the code behind of your asp page, then you dont need to use Request.Form unless your trying to access from remote html form Commented Jan 17, 2014 at 13:39
  • are you posting back to the same page or another page? if you are using runat="server" you should be directly able to access the textbox using the id Commented Jan 17, 2014 at 13:42
  • @dreamweiver When I write VALUE=datepicker.text , I get the error "text is not a member of System.Web.UI.HtmlControls.HtmlInputText" Commented Jan 17, 2014 at 13:43
  • 1
    @HelpASisterOut see my answer below, it should be datepicker.Value instead of datepicker.Text Commented Jan 17, 2014 at 13:45

3 Answers 3

1

Since datepicker has runat="server" property, you can get the value this way:

 Dim VALUE As String
 VALUE = datepicker.Value
Sign up to request clarification or add additional context in comments.

Comments

0

You need to get the TextBox object in your code behind - because it has a runat="server" tag the code can see it:

Dim VALUE As String
VALUE = datepicker.text

EDIT

Apologies, just saw you're using a HTML <input />, rather than a <asp:TextBox /> control. However, the runat="server" should mean your codebehind can still access the object but the .text may not be available... You may need .value or .ToString

2 Comments

When I write VALUE=datepicker.text , I get the error "text is not a member of System.Web.UI.HtmlControls.HtmlInputText"
As said in my edit, should be .Value - Although, you would normally use <asp:textbox which has .Text as a member
0

Try:

VALUE = Request.Form("datepicker")(0)

because Request.Form is a Collection.

Also, because of the runat="server" part, your input is visible server side, so this works too:

VALUE = datepicker.Value

1 Comment

When I write VALUE=datepicker.text , I get the error "text is not a member of System.Web.UI.HtmlControls.HtmlInputText"

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.