我无法使用 '$("# calendar"). FullCalendar('gotoDate', date);'在全日历 v.3.10 js/c#

I can't position the screen on a specific date with '$("# calendar"). FullCalendar (' gotoDate ', date);' in fullcalendar v.3.10 js/c#

我有这个代码

$(document).ready(function () {
    $("#btnsearch").click(function () {
        var res = $("#txtSearch").val();
        res = res.substring(0,9);
        date = moment(res.val(), "DD/MM/YYYY HH:mm").format("DD-MM-YYYY HH:mm");
        $("#calendar").fullCalendar('gotoDate', date);       
    }),

在前端(Default.aspx):

<asp:Button  Text="Search" id="btnsearch" runat="server" /> 

但是当我充电时,活动页面的开始和结束参数设置为今天的日期。:

  public static List<CalendarEvent> getEvents(DateTime start, DateTime end)
  {
           
          List<CalendarEvent> events = new List<CalendarEvent>();
          SqlConnection con = new SqlConnection(connectionString);

          if (System.Web.HttpContext.Current.Session["Username"]!= null) { 
             String user= System.Web.HttpContext.Current.Session["Username"].ToString();
          }

          SqlCommand cmd = new SqlCommand("SELECT Id_xEvent,description, title, event_start, event_end, all_day,color,place FROM xEvent where event_start>=@start AND event_end<=@end", con);
           // SqlCommand cmd = new SqlCommand("SELECT xDataConsRichiesta,xStatoAbbinamento,(convert(varchar,Id_DoTes)  + ' ' + 'data doc: ' + convert(varchar,[DataDoc],103) + ' codice doc: ' +  convert(varchar,[Cd_Do]) + '   tipo documento:' + convert(varchar,[TipoDocumento]) + ' codice cliente:' + convert(varchar,[Cd_CF])) as title ,(' codice cf dest:' + convert(varchar,[Cd_CFDest]) + ' codice cf sede:' + convert(varchar,isnull([Cd_CFSede],'')) +  ' data consegna: ' + convert(varchar,[DataConsegna],103) + ' data trasporto ' + convert(varchar,isnull([TrasportoDataora],''),103) + ' volume: ' +  convert(varchar,isnull([VolumeTotale],'')) + ' luogo scarico: ' + convert(varchar,isnull([Cd_DoLuogoScarico],'')) + ' tipo vettore:' + convert(varchar,isnull([xTipoVett],'')) + ' data cons richiesta: ' + convert(varchar,isnull([xDataConsRichiesta],''),103) + ' data consegna confermata:' + convert(varchar,isnull([xDataConsegnaConfermata],''),103)) as description      FROM [ADB_isolkappa].[dbo].[DOTes] where xDataConsRichiesta BETWEEN @start and @end", con);
          //SqlCommand cmd = new SqlCommand("SELECT event_id, description, title, event_start, event_end, all_day,color FROM Event e inner join dotes d on e.event_id=d.cd_xabbinamenti inner join xabbinamenti a on d.cd_xabbinamenti=a.cd_xabbinamenti where event_start>=@start AND event_end<=@end", con);
          //SqlCommand cmd = new SqlCommand("SELECT (Cd_CF + ' ' + NumeroDocRif + ' ' + DataDocRif + ' ' + numerodoc + ' ' + xCaricoCompleto + ' ' + Cd_DoTrasporto + ' ' + xTipoVett + ' ' + Completo + ' ' + Data_Spedizione + ' ' + xDataConsegnaConfermata + ' ' + DataConsegna + ' ' + Cd_DoLuogoCarico + ' ' + Cd_DoLuogoScarico +' ' + xOKLogistica) as description, title, event_start, event_end, all_day, color FROM Event e inner join dotes d on e.event_id = d.cd_xabbinamenti inner join xabbinamenti a on d.cd_xabbinamenti = a.cd_xabbinamenti where event_start>= @start AND event_end<= @end");
    
          cmd.Parameters.Add("@start", SqlDbType.DateTime).Value = start;
          cmd.Parameters.Add("@end", SqlDbType.DateTime).Value = end;
          //SqlCommand cmdIns = new SqlCommand();
          //string stato="0";

          using (con)
          {
              con.Open();
              SqlDataReader reader = cmd.ExecuteReader();
              while (reader.Read())

在JsonResponse.ashx

中调用了getEvents函数
 foreach (CalendarEvent cevent in EventDAO.getEvents(start, end))
        {
            tasksList.Add(new ImproperCalendarEvent {
                id = cevent.id,

更新:现在是代码

$("#btnsearch").click(function () {
        var res = $("#txtSearch").val();
        res = res.substring(0,10);
        date = moment(res, "DD/MM/YYYY HH:mm").format("DD/MM/YYYY HH:mm");
        $("#calendar").fullCalendar('gotoDate', date);
       }),

在 default.aspx 中: 搜索

它位于请求的日期,但如果我在 03/09/2021 (dd / mm / yyyy) 上搜索事件,则使用 day.For 示例反转月份,它会将自己定位在开始的一周2021 年 8 月 3 日

fullCalendar 3 直接接受 momentJS 对象。您不需要向它传递格式化的字符串。

如果您将格式化字符串传递给它,它会尝试解析它。但它不知道你想要什么格式,所以如果你传递类似 03/09/2021 的东西,它不知道你是否打算采用 dd/mm/yyyy 或 mm/dd/yyyy 格式——它怎么可能告诉?所以它默认将其视为 mm/dd/yyyy(可能是因为这是美国的默认设置和 JavaScript 中的一般标准默认设置)。

date = moment(res.val(), "DD/MM/YYYY HH:mm")

会很好用。