Search code examples
vb.netcode-behindanytime

I am trying pass the value from Any+Time DatePicker/TimePicker to asp.net code behind


I am using Any+Time DatePicker/TimePicker to allow my users to select a date and time in vb.net. But I am unable to retrieve the values in code behind. Can someone please point me in the right direction?

Any+Time URL

I am using the plugin like so:

**aspx head:**
    <script>
            var curDateTime = new Date();
        </script>

**aspx body:**
<input type="text" id="calDwnBgn"/>
<script>AnyTime.picker('calDwnBgn', { askSecond: false, earliest: new Date(curDateTime.getFullYear(), curDateTime.getMonth(), curDateTime.getDate(), curDateTime.getHours(), curDateTime.getMinutes(), 0), format: "%m/%e/%Z %k:%i:00" });</script>

I am trying to access the value in the code behind like this:

Dim txtStrt As TextBox = TryCast(fv1.FindControl("calDwnBgn"), TextBox)

Thanks in advance, Billy


Solution

  • I thought that I had to find the control in my form and then use the TextBox properties to get the value but I was able to get the value in code behind by adding the name attribute to the input tag and calling Page.Request.Form in code behind:

    <input type="text" id="calDwnBgn" name="_calDwnBgn"/>
    

    Then in code behind:

    Page.Request.Form("_calDwnBgn").ToString()