This question is locked. New answers and comments are not allowed.
When I tried to output a control (DateTime in this case) in a Razor partial it caused the StyleSheetRegistrar and ScriptRegistrar to not emit the css nor the JS. My fix was to assign the registrar to a variable and then output it with .ToHtmlString(). This seemed to fix the problem. Any clues as to why this occurs? It seems to only be with partials and the Telerik controls work fine when places in a standard view.
The Partial (_TestPage.cshtml):
Calling page:
_SiteLayout.cshtml:
The Partial (_TestPage.cshtml):
@Html.Telerik().DatePicker().Name("Test")Calling page:
@model PerformanceTracker.Core.Announcement@{ ViewBag.Title = "Edit Announcement"; Layout = "~/Areas/Admin/Views/Shared/_SiteLayout.cshtml";}<div id="breadcrumb"> @Html.ActionLink("Dashboard", "Index", "Admin") > @Html.ActionLink("Announcements", "Index", "Announcement") > Announcement Edit</div><h2>Edit</h2>@using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> <legend>Announcement</legend>@* @Html.Partial("_CreateOrEdit", Model)*@ @Html.Partial("_TestPage") <p> <input type="submit" value="Save" /> </p> </fieldset>}<div> @Html.ActionLink("Back to List", "Index")</div>_SiteLayout.cshtml:
@using Microsoft.Web.Mvc@using PerformanceTracker.Web.Controllers<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title>@ViewBag.Title</title> <link href="@Url.Content("~/Content/Site2.css")" rel="stylesheet" type="text/css" /> <link href="@Url.Content("~/Content/Admin/admin.css")" rel="stylesheet" type="text/css" /> <link href="@Url.Content("~/Content/jquery-ui-1.8.15.custom.css")" rel="stylesheet" type="text/css" /> <script src="@Url.Content("http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js")" type="text/javascript"></script> <script src="@Url.Content("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.jqia.select.js")" type="text/javascript"></script> @{ // The following is to make control rendering in partials work var ssr = Html.Telerik().StyleSheetRegistrar() .DefaultGroup(group => group .DefaultPath("~/Content/Telerik") .Add("telerik.common.css") .Add("telerik.simple.css") ); @Html.Raw(ssr.ToHtmlString()); }</head><body> <div id="sfuser"> <nobr> <strong>Welcome: @(User.Identity.Name)</strong> | @(Html.Raw(Html.ActionLinkForAreas<HomeController>(a => a.Story(), "Starfish Story"))) | <a href="#">Help</a> | @(Html.Raw(Html.ActionLinkForAreas<AuthController>(a => a.LogOff(), "Sign out"))) </nobr> </div> @(Html.Raw(Html.ActionLinkForAreas<HomeController>(c => c.Index(), Html.Image("~/Content/Images/logo4_small.png", "logo", new { id = "logo" }).ToString()))) <a id="wsdotLogo" target="_blank" href="http://www.wsdot.wa.gov"></a> <div id="main-container"> <div id="main"> <div id="content-header"> </div> <div id="content-container"> <div id="content"> <div id="action-bar"> @Html.Partial("~/Areas/Admin/Views/Shared/_adminnavmenu.cshtml") </div> @RenderBody() </div> </div> </div> </div> <!--Scripts here--> @{ // The following is to make control rendering in partials work var sr = Html.Telerik().ScriptRegistrar().DefaultGroup(group => group.Add("telerik.common.min.js")).jQuery(false); @Html.Raw(sr.ToHtmlString()); }</body></html>