razor

Nancy, First razor page not working

三世轮回 提交于 2020-01-13 13:31:40
问题 I'm trying to get a first Razor template working with Nancy, and the first line of my .cshtml... @inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<dynamic> gives me 3 build errors including the following... 'NancyContext' does not contain a definition for 'ApplicationInstance' and no extension method 'ApplicationInstance' accepting a first argument of type 'NancyContext' could be found (are you missing a using directive or an assembly reference?) One very weird thing is that I have three

Asp.Net MVC3 Razor - child items list not posting back from editor

▼魔方 西西 提交于 2020-01-13 11:46:07
问题 I'm trying to create a multi-level editor in MVC3. By multi-level I mean that I would like to be able to edit data for three levels of hierarchy (parent object, parent's child object and collection of sub-child objects). My model roughly looks like: namespace MvcApplication1.Models { public class Parent { public int Id { get; set; } public string Name { get; set; } public Child Child { get; set; } } public class Child { public int Id { get; set; } public string Name { get; set; } public

Embedded view can not be found in ASP.NET Core MVC

孤者浪人 提交于 2020-01-13 10:55:09
问题 I can't reuse my cshtml files from another assembly. Here's the bare-bone sample: Create an ASP.NET Core Web Application project with default template (using Web-Application, Model-View-Controller), and name it ViewReuse Add a class library called ViewLibrary Add a reference to Microsoft.AspNetCore.All metapackage in ViewLibrary Create a folder called Views, then create another folder called Shared, and inside it create a simple cshtml file called ReusedLayout.cshtml Add EmbeddedResources

How to read name of html helper element

只愿长相守 提交于 2020-01-13 08:51:11
问题 Is there in mvc any opportunity to read a name which will be assigned to html control? For example I use this code: <div> @Html.LabelFor(x => x.Name) @Html.TextBoxFor(x => x.Name) @Html.ValidationMessageFor(x => x.Name) @Html.HiddenFor(x => x.Id) <div> I want to display here a TextBox name </div> </div> And I want to get a name of input name. This code is fragment of partial view. Name of element looks like children[1].Name 回答1: @Html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(

Can i call a “shared” editor template from within a “areas” editor template, for the same model?

瘦欲@ 提交于 2020-01-13 08:31:27
问题 I've got an editor template location in: Areas/Posts/Views/Shared/EditorTemplates/Question.cshtml I also have one in: /Views/Shared/EditorTemplates/Question.cshtml For both, the model is the same. What i'm trying to do is within a View in the Posts area, call my editor template in the area, set some HTML and then bubble back up to the main shared editor template. Here's the Posts EditorTemplate: @model xxx.ViewModels.QuestionViewModel @Html.Hidden("Id", (byte)Model.QuestionType) @Html

MVC3 Razor Syntax troubles

杀马特。学长 韩版系。学妹 提交于 2020-01-13 08:28:07
问题 I'm trying to make a very simple view using Razor syntax in MVC3, but it seems I can't get the syntax right. I have a simple table like this <table> <tr> @{ var counter = 0; } @foreach (var category in ViewBag.Categories) { counter++; <td> <input type="checkbox" checked="checked" name="@("category" + category.Code)" /> @category.Description </td> if (counter % 2 == 0) { </tr> <tr> } } </tr> </table> When I insert the and inside the if-statement, I receive this error The using block is missing

Rendering HTML5 Charts in partial views show only blank data

空扰寡人 提交于 2020-01-13 07:27:11
问题 I am trying to display MVC charts as shown in Creating a HTML5 Chart Helper Extension for ASP.NET MVC 4. I have the standard project working but I can't get multiple graphs to show up at once in partial views called by a single view. I will skip reviewing the ChartExtensions.cs and HelperModel.cs classes since they are covered in the article above. I created a controller with a few views: public class WelcomeController : Controller { public ActionResult Index() { ViewBag.Message = "Creating

How to assign value to JavaScript variable under MVC3 Razor with ViewBag [duplicate]

巧了我就是萌 提交于 2020-01-13 06:44:33
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to assign JavaScript value under MVC3 I try to do the following <script type="text/javascript"> var techIDs = ""; @if (ViewBag.URLParameters != null) { techIDs = '@ViewBag.URLParameters'; } </script> But it seems it's a wrong approach. Any clue how it could be done? Thank you! 回答1: try this var techIDs = ""; @if (ViewBag.URLParameters != null) { @:techIDs = '@ViewBag.URLParameters'; } 回答2: Maybe: <script>

Kendo UI reference not working in Razor view

二次信任 提交于 2020-01-12 13:57:15
问题 I am trying to create a Telerik Grid view but when I go to reference kendo it does not recognize it. Visual Studio is giving me an error when I try to reference kendo. This is the code @(Html.Kendo().Grid) and below is the error. 'System.Web.Mvc.HtmlHelper<dynamic>' does not contain a definition for 'Kendo' and no extension method 'Kendo' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<dynamic>' could be found (are you missing a using directive or an assembly reference?) I have

Kendo UI reference not working in Razor view

人走茶凉 提交于 2020-01-12 13:56:31
问题 I am trying to create a Telerik Grid view but when I go to reference kendo it does not recognize it. Visual Studio is giving me an error when I try to reference kendo. This is the code @(Html.Kendo().Grid) and below is the error. 'System.Web.Mvc.HtmlHelper<dynamic>' does not contain a definition for 'Kendo' and no extension method 'Kendo' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<dynamic>' could be found (are you missing a using directive or an assembly reference?) I have