I'm loading a UserControl from my page markup.
The page has a RadStylesheetManager on it.
I want to ensure my page has a particular stylesheet loaded and I don't want to rely on the developer using the control loading the stylesheet on the page explicitlt. So I thought that something like this might work ...
Now mgr is being correctly populated. But when the page runs, I get this ...
So, what am I doing wrong?
--
Stuart
The page has a RadStylesheetManager on it.
I want to ensure my page has a particular stylesheet loaded and I don't want to rely on the developer using the control loading the stylesheet on the page explicitlt. So I thought that something like this might work ...
RadStyleSheetManager mgr = Page.Items[
typeof
(RadStyleSheetManager)]
as
RadStyleSheetManager;
if
(mgr !=
null
)
{
StyleSheetReference ss =
new
StyleSheetReference();
ss.Path = Page.ResolveUrl(
"~/StyleSheets/Popup/InlinePopups.css"
);
ss.Name =
"InlinePopups"
;
mgr.StyleSheets.Add(ss);
}
Now mgr is being correctly populated. But when the page runs, I get this ...
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Telerik.Web.UI.ScriptEntrySlot.GetSerializedAssemblyInfo(ScriptEntry scriptEntry) +208
Telerik.Web.UI.ScriptEntrySlot.SerializeScriptEntry(ScriptEntry scriptEntry) +71
Telerik.Web.UI.ScriptEntryUrlBuilder.TryAddScriptEntry(ScriptEntry scriptEntry) +56
Telerik.Web.UI.ScriptEntryUrlBuilder.RegisterScriptEntry(ScriptEntry scriptEntry) +237
Telerik.Web.UI.RadStyleSheetManager.Page_PreRenderComplete(Object sender, EventArgs e) +373
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +8701886
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1029
So, what am I doing wrong?
--
Stuart