Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

I do have a problem of the real value with this line of Jquery code

$("#<%=lblCheckinViewoData.ClientID%>").datepicker({ dateFormat: "yy/mm/dd" }).datepicker("setDate", (result.reservationInfo[0].Checkin));


Actually this
result.reservationInfo[0].Checkin
gives 2016/03/10, from my pagemethod function in c# which the value is coming from my database.
But in Jquery it is passing a current datetime which is 2016/04/24 to a lblCheckinViewoData.
I dont know if it is because of this setDate parameter.

Please help me getting the real value from my database cause the value in sql server is 2016/03/10

What I have tried:

C#
PageMethods.GetReservationById(aData[index], function (response) {
                    var result = eval("(" + response + ")");
                      if ($('#<%=lblCheckinViewoData.ClientID%>').length > 0) {
                        
                        $("#<%=lblCheckinViewoData.ClientID%>").datepicker({ dateFormat: "yy/mm/dd" }).datepicker("setDate", (result.reservationInfo[0].Checkin));
                        $("#<%=lblCheckoutViewoData.ClientID%>").datepicker({ dateFormat: "yy/mm/dd" }).datepicker("setDate", (result.reservationInfo[0].Checkout));
                      
                        }
                });
Posted
Updated 10-May-16 8:42am
v2
Comments
ZurdoDev 24-Apr-16 22:07pm    
You'll have to debug your code to see what is happening.

You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
JavaScript Debugging[^]

Use the debugger tu see exactly where and why you get a wrong value, Itis a first step to solution.
 
Share this answer
 
There are 2 things which seems incorrect here :

1. you should not format date before setting new date into it.
2. dateFormat should be yy/MM/dd, small m represents minutes.
 
Share this answer
 
Try the following steps:
1. Create ASP.NET Text Box and Apply the Style Display none.
2. Get the Value from the JQuery Function and Pass the value to Created Text Box.
3. In C# get the value from the Text Box directly as textbox.Text.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900