DatePicker Value not correct after postback

Hi:
When i select the DatePick i got the correct date, but when page postback, the value always show the default value.

  <td style="width: 139px">
                    <ej:DatePicker runat="server" ID="datePicker" ClientSideOnChange="onClick" EnablePersistence="true" ></ej:DatePicker>
</td>

On page i choose 2/18/2021. 

Then i choose a data in dropdownlist which postback the page.

But in Code Behind, the value shows: 3/12/2021 which is default value.



3 Replies 1 reply marked as answer

KR Keerthana Rajendran Syncfusion Team March 19, 2021 03:47 PM UTC

Hi Evan, 
 
Thanks for contacting Syncfusion support.  
 
We have checked the reported issue in our end with the provided details. We have rendered ejDatePicker with your code and retrieve this date value through OnSelectedIndexChanged event of ASP DropDown in code behind.  
 
Refer to the following code and screenshots. 
 
<h3>EJ1 DatePicker</h3> 
       <ej:DatePicker runat="server" ID="datePicker" EnablePersistence="true" ></ej:DatePicker> 
    <h3>ASP DropDownList</h3> 
    <asp:DropDownList ID="ddl1" runat="server" OnSelectedIndexChanged="ddl1_SelectedIndexChanged" AutoPostBack="true"> 
        <asp:ListItem Text="Item 1"></asp:ListItem> 
        <asp:ListItem Text="Item 2"></asp:ListItem> 
    </asp:DropDownList> 
 
Protected Sub ddl1_SelectedIndexChanged(sender As Object, e As EventArgs) 
        Dim dateValue As String = Me.datePicker.Value 
    End Sub 
 
The selected value is updated as shown below 
 
 
Code behind: 
 
 
 
We have attached a sample for your reference in the following link 
 
 
Refer to the below UG for more details on DatePicker control. 
 
 
If the issue persists, kindly share the following details to assist you promptly.  
 
  1. Product version used in your sample.
  2. Complete code snippets of your application.
  3. If possible, modify the above sample to replicate the issue in our end to serve you better.
 
Please let us know if you need further assistance.  
 
Regards, 
Keerthana.  


Marked as answer

EH Evan Hang March 31, 2021 07:15 AM UTC

thanks for your reply.
I found i missed the web.js in the page, after i added it works fine now.
    <script src="https://cdn.syncfusion.com/14.1.0.41/js/common/ej.webform.min.js"></script>


KR Keerthana Rajendran Syncfusion Team April 1, 2021 05:12 AM UTC

Hi Evan, 
 
Most welcome. We are glad to know that the issue has been resolved. Please get back to us if you need further assistance.  
 
Regards, 
Keerthana.  


Loader.
Up arrow icon