如何将jquery fullcalendar控件的开始日期设置为服务器日期。 [英] How to set jquery fullcalendar control starting date as server date.

查看:66
本文介绍了如何将jquery fullcalendar控件的开始日期设置为服务器日期。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



我有ASP.NET网络应用程序,我已经创建了一个页面来预订插槽,我在其中使用Jquery fullCanlendar控件来选择倍数天。



但问题是,如果客户更改其机器日期,则此fullcalendar显示当前日期,客户在他/她的机器中设置了什么日期。



例如:

今天是2017年3月20日。如果我将我的机器日期设置为2017年3月19日。那么jquery fullcanlendar控件显示开始日期为2017年3月19日。这是完全错误的。



我尝试了什么:



我想显示fullcalendar控制当前日期,与服务器日期进行比较。



如果客户更改他/她的机器日期&时间,它不应该影响申请。



任何人都可以帮助解决这个问题...





谢谢

解决方案

JavaScript从客户端机器日期时间值中选择日期,这是它的工作原理,如果你想使用服务器日期,然后将当前日期存储在隐藏字段中,并在JavaScript代码中使用它。



 <   asp:HiddenField     ID   =  hdnServerDate    runat   =  server    /  >  



< script>

var serverDate = document .getElementById(' <%= hdnServerDate.ClientID%>')。value;

< / script>





  protected   void  Page_Load( object  sender,EventArgs e)
{
if (!Page.IsPostBack)
{
hdnServerDate.Value = DateTime.Now.ToShortDateString();
}
}





更新的解决方案,基于 F-ES Sitecore 评论



最简单的做法

 var serverDate ='<%= DateTime.Now.ToString(dd MMM yyyy)%>'; 


Dear All,

I have ASP.NET web application, where i have created one page to book slots, in which i'm using Jquery fullCanlendar control to select multiples days.

But the problem here is, if client change its machine date then this fullcalendar is showing the current date, what client had set in his/her machine's date.

for eg:
today is 20th march, 2017. And if i set my machine date to 19th march, 2017. Then the jquery fullcanlendar control is showing the starting date as 19th march, 2017., which is totally wrong.

What I have tried:

I want to display fullcalendar control current date, compare to the server date.

If the client changes his/her machine date & time, it should not effect the application.

Can any one please help to solve this issue...


Thanks

解决方案

JavaScript picks the date from the client Machine DateTime value, This is how it works, If you want to use the server date, then store the current date in a hidden field and the use it across the JavaScript code.

<asp:HiddenField ID="hdnServerDate" runat="server" />


<script>

        var serverDate = document.getElementById('<%= hdnServerDate.ClientID %>').value; 

    </script>



protected void Page_Load(object sender, EventArgs e)
        { 
            if (!Page.IsPostBack)
            {
                hdnServerDate.Value = DateTime.Now.ToShortDateString();              
            }
        }



Updated solution, based on F-ES Sitecore comments

simplest way of doing

var serverDate = '<%= DateTime.Now.ToString("dd MMM yyyy") %>';


这篇关于如何将jquery fullcalendar控件的开始日期设置为服务器日期。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆