This question is locked. New answers and comments are not allowed.
Hi,
I have a an _Layout.cshtml with the following two registrar calls in it ....
I have a page that uses a bunch of telerik controls and when this page runs it loads fine. But when I try to run another page ... as follows
I get the following error ...
All I did was was create the page and strongly type my model (scaffolded - create). And for this specific page the scriptRegistrar doesn't work ...
I found this link ... http://www.telerik.com/community/forums/aspnet-mvc/general/style-sheet-registrar-giving-cannot-write-to-a-closed-textwriter-when-it-is-inside-of-a-partial-view-or-template.aspx but it seems if I take off the Render() call then I don't get the error but then no javascript files are included at all on all my pages using this layout - so none of the controls work.If I have the Render() call then my other pages work but I get that exception on this page ... What's happening here and why?
I also haven't really been able to find any complete documentation on the ScriptRegistrar ... I have found where it looks and I have found out about the debug/ min extensions but nowhere have I actually found any documentation about how it does what it does. Without that I don't know if I'm doing the right thing or not. Also does the telerik.all.js or the telerik.common.js file include the jquery files? What about jquery validate? It's pretty difficult to figure stuff out from the minified versions of these files ... are there unminified versions of these files somewhere?
I've attached a screenshot as well ...
I have a an _Layout.cshtml with the following two registrar calls in it ....
<html><head runat="server"> <title>@ViewBag.Title</title>@Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.min.css") .Add("telerik.telerik.min.css") .Add("validationEngine.jquery.css") .Add("Scheduler.css") .Add("Site.css") .Add("Reports.css") .Add("print.css") .Combined(true) .Compress(true))</head><body> <div> @RenderBody() </div> @{ Html.Telerik().ScriptRegistrar().Scripts(scripts => scripts.AddGroup("everything", group => group.Add("telerik.common.js") .Add("jquery-1.7.1.js") .Add("jquery.validate.js") .Add("~/Scripts/jquery.validate.unobtrusive.min.js") )).Render(); } @RenderSection("postJavascript", false)</body></html>I have a page that uses a bunch of telerik controls and when this page runs it loads fine. But when I try to run another page ... as follows
@model ViewModels.CreateScheduleViewModel@{ ViewBag.Title = "CreateSchedule2"; Layout = "~/Views/Shared/_Layout.cshtml";}@section postJavascript{ <script src="@Url.Content("~/Scripts/2012.2.607/jquery-1.7.1.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> @Html.ValidationSummary(true)}<h2>CreateSchedule2</h2>@using (Html.BeginForm()) { <fieldset> <legend>CreateScheduleViewModel</legend> <div class="editor-label"> @Html.LabelFor(model => model.DefaultClub) </div> <div class="editor-field"> @Html.EditorFor(model => model.DefaultClub) @Html.ValidationMessageFor(model => model.DefaultClub) </div> <div class="editor-label"> @Html.LabelFor(model => model.TimePickerInterval) </div> <div class="editor-field"> @Html.EditorFor(model => model.TimePickerInterval) @Html.ValidationMessageFor(model => model.TimePickerInterval) </div> <div class="editor-label"> @Html.LabelFor(model => model.MinStartDate) </div> <div class="editor-field"> @Html.EditorFor(model => model.MinStartDate) @Html.ValidationMessageFor(model => model.MinStartDate) </div> <div class="editor-label"> @Html.LabelFor(model => model.MaxStartDate) </div> <div class="editor-field"> @Html.EditorFor(model => model.MaxStartDate) @Html.ValidationMessageFor(model => model.MaxStartDate) </div> <div class="editor-label"> @Html.LabelFor(model => model.DefaultStartDate) </div> <div class="editor-field"> @Html.EditorFor(model => model.DefaultStartDate) @Html.ValidationMessageFor(model => model.DefaultStartDate) </div> <div class="editor-label"> @Html.LabelFor(model => model.MinAvailableDate) </div> <div class="editor-field"> @Html.EditorFor(model => model.MinAvailableDate) @Html.ValidationMessageFor(model => model.MinAvailableDate) </div> <div class="editor-label"> @Html.LabelFor(model => model.MaxAvailableDate) </div> <div class="editor-field"> @Html.EditorFor(model => model.MaxAvailableDate) @Html.ValidationMessageFor(model => model.MaxAvailableDate) </div> <div class="editor-label"> @Html.LabelFor(model => model.DefaultAvailableDate) </div> <div class="editor-field"> @Html.EditorFor(model => model.DefaultAvailableDate) @Html.ValidationMessageFor(model => model.DefaultAvailableDate) </div> <p> <input type="submit" value="Save" /> </p> </fieldset> @(Html.Telerik().DropDownList() .Name("ClubDropDown") .BindTo(new SelectList(Model.Clubs, "ClubNo", "ClubNameFormatted")) .HtmlAttributes(new { style = "width:300px" }) .SelectedIndex(Model.DefaultClub) .Placeholder("Select which Club") .ClientEvents(events => events .OnChange("clubDropDownChange") ) )}<div> @Html.ActionLink("Back to List", "Index")</div>I get the following error ...
[ObjectDisposedException: Cannot write to a closed TextWriter.] System.IO.StringWriter.Write(Char[] buffer, Int32 index, Int32 count) +12505613 System.IO.TextWriter.WriteLine(String value) +204 Telerik.Web.Mvc.UI.ScriptRegistrar.WriteScriptSources(TextWriter writer) in f:\109\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ScriptRegistrar\ScriptRegistrar.cs:332 Telerik.Web.Mvc.UI.ScriptRegistrar.Write(TextWriter writer) in f:\109\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ScriptRegistrar\ScriptRegistrar.cs:314 Telerik.Web.Mvc.UI.ScriptRegistrar.Render() in f:\109\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ScriptRegistrar\ScriptRegistrar.cs:300 ASP._Page_Views_Shared__Layout_cshtml.Execute() in c:\SVN\code\branches\development\systems\CARE\apps\CAREweb.NET\Views\Shared\_Layout.cshtml:31 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +173 System.Web.WebPages.WebPageBase.Write(HelperResult result) +89 System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +234 System.Web.WebPages.WebPageBase.PopContext() +222 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +384 System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825572 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +825600 System.Web.Mvc.Controller.ExecuteCore() +159 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335 System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62 System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20 System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375All I did was was create the page and strongly type my model (scaffolded - create). And for this specific page the scriptRegistrar doesn't work ...
I found this link ... http://www.telerik.com/community/forums/aspnet-mvc/general/style-sheet-registrar-giving-cannot-write-to-a-closed-textwriter-when-it-is-inside-of-a-partial-view-or-template.aspx but it seems if I take off the Render() call then I don't get the error but then no javascript files are included at all on all my pages using this layout - so none of the controls work.If I have the Render() call then my other pages work but I get that exception on this page ... What's happening here and why?
I also haven't really been able to find any complete documentation on the ScriptRegistrar ... I have found where it looks and I have found out about the debug/ min extensions but nowhere have I actually found any documentation about how it does what it does. Without that I don't know if I'm doing the right thing or not. Also does the telerik.all.js or the telerik.common.js file include the jquery files? What about jquery validate? It's pretty difficult to figure stuff out from the minified versions of these files ... are there unminified versions of these files somewhere?
I've attached a screenshot as well ...