I have just added my first MVC to my IIS using Windows7. The first problem I had was just getting a blank screen when I loaded in browser. I published the MVC to a directory called calendar in my wwwroot directory. I soon realized, using developer tools in chrome, the browser rendered without any CSS being found and that is why my screen was blank. I adjusted the paths for my CSS files from “Scripts/dhtmlxscheduler_glossy.css” to “http://localhost/calendar/Scripts/dhtmlxscheduler_glossy.css”. Naturally I had to change the path for my js files too. At this point, I can put localhost/Calendar/Data?timeshift=300 404 (Not Found). I tried to change the path in the Index.apsx, and I still get the problem. I am not sure what I am doing wrong. I am using 4.0.30319 framework and I am in integrated mode in IIS 7.5, it can obviously find the Index.aspx in my Views/Calendar/ directory, but for some reason it cannot load or save ( Data.aspx and Save.aspx ). I am relatively new to MVC. Any help would be appreciated. I am trying to use this for my programming class that has just started.
Hi,
try adding site with iis manager, then you’ll be sure that site folder is configured as asp.net application, and that mvc routing is enabled.
As for incorrect paths, you can redefine them as decribed here:
http://scheduler-net.com/docs/faq.html#qscheduler_works_in_the_development_environment_but_does_not_work_when_i_deploy_to_the_website
I originally added this to IIS using the manager. I can get the calendar to show, It just won’t load or save data. I tried Url.Content and got an error. I then tried UrlHelper.Content and got the same reference error. I am just a student and relatively new to this. Here is my code:
[code]<%@ Page Language=“C#” Inherits=“System.Web.Mvc.ViewPage” %>
Index
html, body
{
height:100%;
padding:0px;
margin:0px;
}
/event in day or week view/
.dhx_cal_event.past_event div{
background-color:purple !important;
color:white !important;
}
/multi-day event in month view/
.dhx_cal_event_line.past_event{
background-color:purple !important;
color:white !important;
}
/event with fixed time, in month view/
.dhx_cal_event_clear.past_event{
color:purple !important;
}
/Testing Color/
.dhx_cal_event.event_test div, .dhx_cal_event_line.event_test{
background-color: orange !important;
color: blue !important;
}
/Testing Color/
.dhx_cal_event_clear.event_test{
color: blue !important;
}
/Visit Color/
.dhx_cal_event.event_cv div, .dhx_cal_event_line.event_cv{
background-color: #add8e6 !important;
color: #8b0000 !important;
}
/Visit Color/
.dhx_cal_event_clear.event_cv{
color: #8b0000 !important;
}
/Vacation Color/
.dhx_cal_event.event_vac div, .dhx_cal_event_line.event_vac{
background-color: #e0ffff !important;
color: #008b8b !important;
}
/Vacation Color/
.dhx_cal_event_clear.event_vac{
color: #008b8b !important;
}
/Training Color/
.dhx_cal_event.event_tr div, .dhx_cal_event_line.event_tr{
background-color: #CC9900 !important;
color: #FFFF00 !important;
}
/Training Color/
.dhx_cal_event_clear.event_tr{
color: #FFFF00 !important;
}
/Internal Meeting Color/
.dhx_cal_event.event_im div, .dhx_cal_event_line.event_im{
background-color: Red !important;
color: #999966 !important;
}
/Internal Meeting Color/
.dhx_cal_event_clear.event_im{
color: #999966 !important;
}
/Offsite Meeting Color/
.dhx_cal_event.event_om div, .dhx_cal_event_line.event_om{
background-color: #CCFFCC !important;
color: #FF3300 !important;
}
/Offsite Meeting Color/
.dhx_cal_event_clear.event_om{
color: #FF3300 !important;
}
/Education Color/
.dhx_cal_event.event_pro div, .dhx_cal_event_line.event_pro{
background-color: #000000 !important;
color: #FFFFFF !important;
}
/Education Color/
.dhx_cal_event_clear.event_pro{
color: #000000 !important;
}
function init() {
scheduler.templates.tooltip_date_format = scheduler.date.date_to_str("%Y-%m-%d %H:%i");
scheduler.config.xml_date = “%m/%d/%Y %H:%i”;
scheduler.config.hour_date = “%h:%i %A”; // formats hours so they are AM and PM and not 24 hour mode.
scheduler.config.repeat_date = “%m%d%Y”;
scheduler.config.lightbox.sections =
[
{ name: “subject”, height: 20, type: “textarea”, map_to: “subject”, focus: true },
{ name: “location”, height: 20, map_to: “location”, type: “select”, options:
[
//Selections for location
{key: ‘northMainOffice’, label: “(North) Main Office” },
{ key: ‘southMainOffice’, label: “(South) Main Office” },
{ key: ‘lab’, label: “Lab” },
{ key: ‘northTrainingRoom’, label: “North 50th Training Room” },
{ key: ‘plantTour’, label: “Tour” },
{ key: ‘vendor’, label: “Vendor” }
]
},
{ name: “body”, height: 170, map_to: “text”, type: “textarea” },
{ name: “time”, height: 72, type: “time”, map_to: “auto” },
{ name: “eventType”, height: 20, type: “radio”, map_to: “eventType”, vertival: true, options:
[
//Buttons Choices for Meeting Types
{key: ‘test’, label: “Testing” },
{ key: ‘v’, label: “Visit” },
{ key: ‘vac’, label: “Vacation” },
{ key: ‘tr’, label: “Training” },
{ key: ‘im’, label: “Internal Meeting” },
{ key: ‘om’, label: “Offsite Meeting” },
{ key: ‘edu’, label: “Education” }
]
}
];
scheduler.templates.event_class = function (start, end, event) {
if (start < (new Date())) //if event has past
return “past_event”; //past event for the css style to change color.
if (event.eventType)//sets if a location has been chosen
return “event_” + event.eventType; // returns the eventType for use with css
return “”;
}
scheduler.config.first_hour = 4; // makes first hour shown 4:00AM
scheduler.locale.labels.section_subject = “Subject”;
scheduler.locale.labels.section_location = “Where?”;
scheduler.locale.labels.section_body = “Information”;
scheduler.locale.labels.section_eventType = “Type of Event?”;
scheduler.config.details_on_create = true;
scheduler.config.details_on_dblclick = true;
scheduler.config.event_duration = 60; //specify event duration in minutes for auto end time
scheduler.config.auto_end_date = true;
scheduler.config.full_day = true;
scheduler.config.multi_day = true;
scheduler.config.mark_now = true;
scheduler.config.time_step = 15;
scheduler.config.start_on_monday = false; //makes first day of the week sunday
scheduler.config.cascade_event_display = true; // enable rendering, default value = false
scheduler.config.cascade_event_count = 8; // how many events will be displayed in cascade style (max), default value = 4
scheduler.config.cascade_event_margin = 30; // margin between events, default value = 30
scheduler.init("scheduler_here", new Date(), "month");
scheduler.templates.lightbox_header = function (start, end, event) {
return event.subject;
} //puts the calendar post subject in the header
scheduler.load("/Calendar/Data");
var dp = new dataProcessor("/Calendar/Save");
dp.init(scheduler);
dp.setTransactionMode("POST", false);
}
</script>
</head>
<body onload="init()">
<div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
<div class="dhx_cal_navline">
<div class="dhx_cal_prev_button"> </div>
<div class="dhx_cal_next_button"> </div>
<div class="dhx_cal_today_button"></div>
<div class="dhx_cal_date"></div>
<div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div>
<div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
<div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
</div>
<div class="dhx_cal_header">
</div>
<div class="dhx_cal_data">
</div>
</div>
</body>
</html>[/code]
Here is my CalendarController.cs:
[code]using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MyCalendar.Models;
namespace MyCalendar.Controllers
{
public class CalendarActionResponseModel
{
public String Status;
public Int64 Source_id;
public Int64 Target_id;
public CalendarActionResponseModel(String status, Int64 source_id, Int64 target_id)
{
Status = status;
Source_id = source_id;
Target_id = target_id;
}
}
public class CalendarController : Controller
{
//
// GET: /Calendar/
public ActionResult Index()
{
return View();
}
public ActionResult Data()
{
MyAppointmentsDataContext data = new MyAppointmentsDataContext();
return View(data.Appointments);
}
public ActionResult Save(Appointment changedAppointment, FormCollection actionValues)
{
String action_type = actionValues["!nativeeditor_status"];
Int64 source_id = Int64.Parse(actionValues["id"]);
Int64 target_id = source_id;
MyAppointmentsDataContext data = new MyAppointmentsDataContext();
try{
switch (action_type)
{
case "inserted":
data.Appointments.InsertOnSubmit(changedAppointment);
break;
case "deleted":
changedAppointment = data.Appointments.SingleOrDefault(a => a.id == source_id);
data.Appointments.DeleteOnSubmit(changedAppointment);
break;
default: // "updated"
changedAppointment = data.Appointments.SingleOrDefault(a => a.id == source_id);
UpdateModel(changedAppointment);
break;
}
data.SubmitChanges();
target_id = changedAppointment.id;
}
catch
{
action_type = "error";
}
return View(new CalendarActionResponseModel(action_type, source_id, target_id));
}
}
}
[/code]
Finally Here is the code for Data.aspx:
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" ContentType="text/xml" %>
<data>
<% foreach (var myappointment in Model) { %>
<event id="<%=myappointment.id%>">
<start_date><%= String.Format("{0:MM/dd/yyyy HH:mm}",myappointment.start_date) %></start_date>
<end_date><%= String.Format("{0:MM/dd/yyyy HH:mm}",myappointment.end_date) %></end_date>
<text><%= (string)myappointment.Text %></text>
<subject><%= (string)myappointment.Subject %></subject>
<location><%= (string)myappointment.Location %></location>
<eventType><%= (string)myappointment.EventType %></eventType>
</event>
<% } %>
</data>
And here is the code for Save.aspx
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<MyCalendar.Controllers.CalendarActionResponseModel>" ContentType="text/xml"%>
<data>
<action type="<%= Model.Status %>" sid="<%= Model.Source_id %>" tid="<%= Model.Target_id %>"></action>
</data>
Where do I need to add the Url.Content in order to get this to run correctly in IIS???
Hi,
try setting scheduler.load and dataprocessor urls with url helper:scheduler.load("<%= Url.Action("Data", "Calendar") %>");
var dp = new dataProcessor("<%= Url.Action("Save", "Calendar") %>");
instead of Url.Action you may also use something like this:
scheduler.load("<%= Url.Content("~")%>Calendar/Data");
Thanks. This worked correctly!
same case for me,
my program can show the data in calendar, but can not save further action (in dev env it is fine),
cannot save new event / delete event and modify existing event.
setting is same with bwhite