2015-01-01 3 views
1

스크립트를 페이지에 추가하려고하지만 아무 일도 일어나지 않으면 일정이 나타나지 않습니다. 목표는 웹 서비스가 목록을 가져 오지 않도록하려는 이벤트 목록으로 달력을 렌더링하는 것입니다.페이지로드시 스크립트 추가 C#

string CalendarScript = @"<script type=""text/javascript""> 
     jQuery(function ($) { 

      /* initialize the external events 
       -----------------------------------------------------------------*/ 

      $('#external-events div.external-event').each(function() { 

       // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/) 
       // it doesn't need to have a start or end 
       var eventObject = { 
        title: $.trim($(this).text()) // use the element's text as the event title 
       }; 

       // store the Event Object in the DOM element so we can get to it later 
       $(this).data('eventObject', eventObject); 

       // make the event draggable using jQuery UI 
       $(this).draggable({ 
        zIndex: 999, 
        revert: true,  // will cause the event to go back to its 
        revertDuration: 0 // original position after the drag 
       }); 

      }); 

      /* initialize the calendar 
      -----------------------------------------------------------------*/ 

      var date = new Date(); 
      var d = date.getDate(); 
      var m = date.getMonth(); 
      var y = date.getFullYear(); 


      var calendar = $('#calendar').fullCalendar({ 
       lang: ""pt"", 
       allDaySlot: false, 
       minTime: ""07:00:00"", 
       maxTime: ""23:59:59"", 

       defaultView: 'agendaWeek', 

       header: { 
        left: ' ', 
        center: ' ', 
        right: ' ' 
       }, 
       events: [ " + EventsList + @" 
       ] 
    , 

       columnFormat: { 

        week: 'dddd', 

       }, 

       editable: false, 
       droppable: false, // this allows things to be dropped onto the calendar !!! 

       selectable: false, 
       selectHelper: false 


      }); 


     }) 
    </script>"; 
     ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "InitCalendarEvents", CalendarScript, false); 

은 이벤트 목록이

{ title: 'Some Event', start: new Date(y, m, d - 2, 16, 00), end: new Date(y, m, d - 2, 17, 00), allDay: false, color: 'blue !important', textColor: 'white !important' } 

답변

1

두 가지처럼입니다. 첫째, 스크립트 관리자에서 스크립트를 등록 할 때 자바 스크립트 만 스크립트 태그로 묶지 말아야합니다. 둘째, add_load 이벤트에서 함수가 발생하기를 원할 것입니다. 자바 스크립트 함수에 대한 매개 변수가 자바 스크립트 기능이 아닌 HTML 스크립트 요소입니다

this.Page.ClientScript.RegisterStartupScript(
    this.GetType(), 
    "StartupScript", 
    "Sys.Application.add_load(function() { functioncall(); });", 
    true); 

참고 :

은 샘플 코드 조각입니다. 또한 함수가 구성되어 있지 않음 Sys.Application.add_load

두 가지를 수행하면 스크립트가 실행되어야합니다. 질문 Sys.application.add_load vs document ready vs pageload은 아마도 당신이하려고하는 것과 관련이 있습니다.

관련 문제