similar to another post on the forum, I'm receiving the error:
j is null
on the line:
var l=(j.get_allowDelete()!=null)?j.get_allowDelete():this.get_allowDelete();
This occurs when I mouse over a calendar event. I'm using radtooltip to display a tooltip with details of the event. I'm also using a custom provider (based on Exchange managed web services).
I have programmed this as a web control (.ascx) that then gets called to display on my page.
source of LiveCalendar.ascx.cs:
any help appreciated
Jonathan
j is null
on the line:
var l=(j.get_allowDelete()!=null)?j.get_allowDelete():this.get_allowDelete();
This occurs when I mouse over a calendar event. I'm using radtooltip to display a tooltip with details of the event. I'm also using a custom provider (based on Exchange managed web services).
I have programmed this as a web control (.ascx) that then gets called to display on my page.
source of LiveCalendar.ascx.cs:
using
System;
using
System.Drawing;
using
System.IO;
using
System.Web.UI;
using
System.Web.UI.HtmlControls;
using
CRD.LiveCalendars.Helpers;
using
CRD.LiveCalendars.Models;
using
CRD.LiveCalendars.Providers;
using
Telerik.Web.UI;
using
System.Web.UI.WebControls;
namespace
CRD.LiveCalendars
{
public
partial
class
LiveCalendar : System.Web.UI.UserControl
{
public
ViewTabs DefaultViewTab {
get
;
set
; }
public
string
ExchangeServerName {
get
;
set
; }
public
string
ExchangeMailbox {
get
;
set
; }
public
string
UserName {
get
;
set
; }
public
string
UserDomain {
get
;
set
; }
public
string
UserPass {
get
;
set
; }
public
bool
ShowViewDay {
get
;
set
; }
public
bool
ShowViewWeek {
get
;
set
; }
public
bool
ShowViewMonth {
get
;
set
; }
public
int
CalendarWidth {
get
;
set
; }
int
dayStartHour {
get
;
set
; }
public
int
DayStartHour
{
get
{
if
(dayStartHour > 0)
return
dayStartHour;
else
return
9;
}
set
{ dayStartHour = value; }
}
int
dayStartMinute {
get
;
set
; }
public
int
DayStartMinute
{
get
{
if
(dayStartMinute > 0)
return
dayStartMinute;
else
return
0;
}
set
{ dayStartMinute = value; }
}
int
dayEndHour {
get
;
set
; }
public
int
DayEndHour
{
get
{
if
(dayEndHour > 0)
return
dayEndHour;
else
return
17;
}
set
{ dayEndHour = value; }
}
int
dayEndMinute {
get
;
set
; }
public
int
DayEndMinute
{
get
{
if
(dayEndMinute > 0)
return
dayEndMinute;
else
return
0;
}
set
{ dayEndMinute = value; }
}
protected
void
Page_Init(
object
sender, EventArgs e)
{
string
serverPath =
string
.Format(
"http://{0}/EWS/Exchange.asmx"
, ExchangeServerName);
ExchangeProvider provider;
try
{
provider =
new
ExchangeProvider(serverPath, UserName, UserPass, UserDomain, ExchangeMailbox);
}
catch
(Exception)
{
provider =
null
;
}
if
(provider ==
null
)
{
RadScheduler1.Visible =
false
;
DisplayError();
}
else
{
RadScheduler1.Provider = provider;
}
}
private
void
DisplayError()
{
}
protected
void
Page_Load(
object
sender, EventArgs e)
{
RadScheduler1.AppointmentDataBound +=
new
Telerik.Web.UI.AppointmentDataBoundEventHandler(RadScheduler1_AppointmentDataBound);
RadScheduler1.AppointmentCreated +=
new
AppointmentCreatedEventHandler(RadScheduler1_AppointmentCreated);
if
(!Page.IsPostBack)
SetupCalendar();
SetupWebResources();
}
private
void
SetupWebResources()
{
HtmlLink lnkCss =
new
HtmlLink();
lnkCss.Attributes.Add(
"media"
,
"screen"
);
lnkCss.Attributes.Add(
"type"
,
"text/css"
);
lnkCss.Attributes.Add(
"rel"
,
"Stylesheet"
);
////Get the name of the Web Resource.
String resourceName =
"CRD.LiveCalendars.assets.styles.LiveCalendar.css"
;
////Get the type of the class.
Type resourceType =
typeof
(CRD.LiveCalendars.LiveCalendar);
//// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
lnkCss.Href = cs.GetWebResourceUrl(resourceType, resourceName);
Page.Header.Controls.Add(lnkCss);
Page.Header.Controls.AddAt(0, lnkCss);
}
private
void
SetupCalendar()
{
// show only tabs provided in xml, and only if there is more than one option
RadScheduler1.DayView.UserSelectable = ShowViewDay;
RadScheduler1.WeekView.UserSelectable = ShowViewWeek;
RadScheduler1.MonthView.UserSelectable = ShowViewMonth;
// there must always be at least one ViewType. the method that parses the xml settings returns "WeekView" if nothing else is provided.
RadScheduler1.SelectedView = (SchedulerViewType)Enum.Parse(
typeof
(SchedulerViewType), DefaultViewTab.ToString());
RadScheduler1.TimelineView.UserSelectable =
false
;
RadScheduler1.EnableDatePicker =
false
;
//RadScheduler1.TimeZoneOffset = new TimeSpan(-7, 0, 0);
//RadScheduler1.TimeZoneOffset = new TimeSpan(-8, 0, 0);
RadScheduler1.DayStartTime =
new
TimeSpan(DayStartHour, DayStartMinute, 0);
RadScheduler1.DayEndTime =
new
TimeSpan(DayEndHour, DayEndMinute, 0);
RadScheduler1.Width = CalendarWidth;
}
void
RadScheduler1_AppointmentDataBound(
object
sender, Telerik.Web.UI.SchedulerEventArgs e)
{
Appointment a = e.Appointment;
a.BackColor = ColorTranslator.FromHtml(AppointmentHelpers.ColourFromDescription(a.Description));
a.Attributes.Add(
"content"
, AppointmentHelpers.CleanUpDescription(a.Description));
a.CssClass =
"apo"
;
// and "lighten the load" by resetting the heavy, MS-laden description to a text only description
// I don't think description is actually used... but it *is* serialized out into JSON and embedded
// in the page source
a.Description =
""
;
// AppointmentFormatters.StripHtml(a.Description);
}
void
RadScheduler1_AppointmentCreated(
object
sender, AppointmentCreatedEventArgs e)
{
if
(e.Appointment.Visible)
{
string
id = e.Appointment.ID.ToString();
foreach
(
string
domElementID
in
e.Appointment.DomElements)
{
Telerik.Web.UI.RadToolTip tt =
new
RadToolTip()
{
TargetControlID = domElementID,
ShowEvent = ToolTipShowEvent.OnMouseOver,
RelativeTo = ToolTipRelativeDisplay.Element,
Text = BuildToolTipHtml(e.Appointment),
IsClientID =
true
,
ShowDelay = 0,
AutoCloseDelay = 0
// popup continues to be displayed as long as moused over
};
phDefaultHolder.Controls.Add(tt);
}
}
}
private
string
BuildToolTipHtml(Appointment appo)
{
string
description = appo.Attributes[
"content"
];
HtmlGenericControl div =
new
HtmlGenericControl(
"div"
);
div.Attributes.Add(
"class"
,
"tooltip"
);
HtmlGenericControl divApoTitle =
new
HtmlGenericControl(
"div"
);
divApoTitle.Attributes.Add(
"class"
,
"ToolTipAppointmentTitle"
);
divApoTitle.InnerHtml = appo.Subject;
HtmlGenericControl divApoTimes =
new
HtmlGenericControl(
"div"
);
divApoTimes.Attributes.Add(
"class"
,
"ToolTipAppointmentTimes"
);
divApoTimes.InnerHtml =
string
.Format(
"{0} - {1}"
, appo.Start.ToLocalTime().ToString(
"t"
), appo.End.ToLocalTime().ToString(
"t"
));
HtmlGenericControl divApoDescription =
new
HtmlGenericControl(
"div"
);
divApoDescription.Attributes.Add(
"class"
,
"ToolTipAppointmentDescription"
);
divApoDescription.InnerHtml = description;
div.Controls.Add(divApoTitle);
div.Controls.Add(divApoTimes);
div.Controls.Add(divApoDescription);
//div.InnerHtml = description;
string
result =
string
.Empty;
using
(StringWriter sw =
new
StringWriter())
{
var writer =
new
System.Web.UI.HtmlTextWriter(sw);
div.RenderControl(writer);
result = sw.ToString();
writer.Close();
}
return
result;
}
}
}
any help appreciated
Jonathan