I was wondering if, if possible, the best way to make partial use of the new razor viewing mechanism. I understand that this is something that was not completely completed by the time
I am currently using RenderPage to render a custom control:
@RenderPage("~/Views/Shared/LocaleUserControl.cshtml",ViewData.Model)
The page calling the RenderPage uses a layout page (master) with three defined sections: TitleContent, HeadContent, and Maincontent. When I try to display my control on this page, it seems that these sections are also necessary - they should be necessary only on the calling page and be present. I get the following message, regardless of whether I include sections in my partial view (obviously, I don't want to include these sections, but that seemed like an interesting debugging point ...).
The following sections were but were not the layout page '~ / Views / Shared / LocaleUserControl.cshtml': TitleContent; HeadContent; Maincontent
My partial view is as follows (adapted from the following link ):
@inherits System.Web.Mvc.WebViewPage<LocaleBaseModel> @using System.Web.UI; <p> @Html.LabelFor(model => Model.CountryName) <br /> @Html.DropDownListFor(model => Model.CountryName,null, string.Empty, new { @class = "text", accesskey="u"}) </p> <p> @Html.LabelFor(model => Model.StateProvince) <br /> @Html.DropDownListFor(model => Model.StateProvince, null, string.Empty, new { @class = "text", accesskey="t" }) </p> <script type="text/javascript"> $(function () { var countries = $("#CountryName"); var statesprovinces = $("#StateProvince"); countries.change(function () { statesprovinces.find('option').remove(); var url = '@Url.Action("GetStatesProvinces", "Base")'; $.getJSON(url, { countryId: countries.val() }, function (data) { $(data).each(function () { $("<option value=" + this.ID + ">" + this.Name + "</option>").appendTo(statesprovinces); }); }); }); }); </script>
c # asp.net-mvc razor
JP. Aug 1 '10 at 6:00 2010-08-01 06:00
source share