Abraham Olatubosun

Abraham Olatubosun

  • NA
  • 471
  • 113.6k

Jquery datepicker value disappear after a submit button post

Sep 17 2018 12:56 PM
Hi,
i believe this question meet you all in good health,
 My organisation have this application that save's patient clinic visit history written in VB.NET, i was asked to add some date validation rules to it so i used JQuery Datepicker. All worked fine till when patient record want to be saved, i found out that, the JQuery Datepicker always lost it value on the selected textbox when ever the "Submit button is click" AutopostBack issue.
 And storing empty space as Date is invalid.
 
Any solution is highly appreciated.
 
Thank you all 
 
  1. <link href="Content/bootstrap.min.css" rel="stylesheet" />  
  2.     <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/>  
  3.     <script src="https://code.jquery.com/jquery-1.12.4.js" type="text/javascript"></script>  
  4.   <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js" type="text/javascript"></script>  
  5.   
  6.             
  7.         <script type="text/javascript">  
  8.              
  9.                 $(function () {  
  10.   
  11.                     $("#<%=txtPat_disp_date.ClientID%>").datepicker({  
  12.                         dateFormat: "dd-mm-yy",  
  13.                         changeMonth: true,  
  14.                         changeYear: true,  
  15.                         maxDate: '0',  
  16.                         showButtonPanel: true  
  17.                     });  
  18.  });  
  1. Dim sql As String = "Insert into art_visit_adult (enrol_id,"  
  2.        sql += "visit_date) VALUES(@enrol_id,@visit_date)"  
  3. Using d As New SqlConnection(cons.ConnectMe)  
  4.            d.Open()  
  5.            Dim cmd As New SqlCommand(sql, d)  
  6.            cmd.Parameters.AddWithValue("@enrol_id", DbType.String).Value = txtEnrol_id.Text.Trim  
  7.            cmd.Parameters.AddWithValue("@visit_date", SqlDbType.SmallDateTime).Value = Convert.ToDateTime(txtVisit_date.Text.ToString())   
  8. cmd.ExecuteNonQuery()  
  9.            d.Close()  
  10.            cmd.Dispose()  

Answers (1)