razor

Asp MVC Dropdown List Selected Value not selected

本秂侑毒 提交于 2021-02-10 05:48:07
问题 I have the following dropdown list but the selected value doesn't seem to working. It defaults to first item in list. private List<string> GetTransmissions() { List<string> Transmission = new List<string>(); Transmission.Add("Automatic"); Transmission.Add("Manual"); return Transmission; } Car car = _repository.GetCarDetails(id); ViewBag.Transmission = new SelectList(GetTransmissions(), car.Transmission); In my view I have: @Html.DropDownList("Transmission", (IEnumerable<SelectListItem>

Bootstrap not working in Razor Pages

三世轮回 提交于 2021-02-10 05:16:06
问题 Bootstrap is working in my index page and other pages which are by default generate....But the folder i create inside pages and scaffold using crud on those pages bootstrap is not working.....I tried the same thing in asp.net core 2 mvc template and it works fine. Here is my create view @page @model Memberships.Pages.Section_Page.CreateModel @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>Create</title> </head> <body> <h4>Section<

Issue with updating model on AJAX “POST”

[亡魂溺海] 提交于 2021-02-09 07:30:36
问题 I'm trying to update my model without refreshing the page. I'm using a wysiwyg inline editor that I have on many places on my page. The editor can be placed anywhere on the page, it could look like this: <div id="1" class="click2edit">@Model.Header</div> <div id="2" class="click2edit">@Model.Content</div> Each editors div have a SaveButton that goes to this jquery, ajax below. What it does is: When I hit the save button for example the <div id="1" class="click2edit">@Model.Header</div> It

Using JQuery Variable within Razor

一曲冷凌霜 提交于 2021-02-08 08:43:18
问题 How do you make use of a jquery variable within Url.Action within jquery? var id = "10"; window.location.href = '@Url.Action("MyAction", "MyController", new { id })'; Thanks 回答1: try, replace function by placing a token: var id = "10"; var actionUrl = "@Url.Action("MyAction","MyController", new { Id= "TabId" })"; window.location.href = actionUrl.replace("TabId", id); 回答2: If I understand you question correctly.. To achieve this I would make an Ajax call with your jQuery to a Razor page

Passing a model to a partial view

我的未来我决定 提交于 2021-02-08 06:19:41
问题 I have an _Address partial view. This partial view contains all of the address fields that match the Address Model. At the top of this view I set the model like this: @model Data.Address In my CustomerInfo view I try the following to render the Address fields as part of my form: @Html.Partial("~/Views/Shared/Partial/_Address.cshtml") The error I am getting is: The model item passed into the dictionary is of type 'Data.Customer', but this dictionary requires a model item of type 'Data.Address'

How to access the kendo grid footer template value

时间秒杀一切 提交于 2021-02-08 06:17:19
问题 i have developed a web application using kendo tools and asp.net mvc4.. below is a screenshot of the grid i'm using and i need to get the value of footer under the "Total Stock" column.. according to this, the total value is $74,050.85.. i need to assign this value to a text box or a variable and use it in some where else but there no positive feedback from the online resources.. can somebody please tell me that how to get a value from footer template .. 回答1: You can get the footer aggregate

How to access the kendo grid footer template value

大城市里の小女人 提交于 2021-02-08 06:17:15
问题 i have developed a web application using kendo tools and asp.net mvc4.. below is a screenshot of the grid i'm using and i need to get the value of footer under the "Total Stock" column.. according to this, the total value is $74,050.85.. i need to assign this value to a text box or a variable and use it in some where else but there no positive feedback from the online resources.. can somebody please tell me that how to get a value from footer template .. 回答1: You can get the footer aggregate

How to use asp-for TagHelper combined with Reflection

强颜欢笑 提交于 2021-02-08 05:14:40
问题 I have a class Foo which contains a lot of properties, I'd like to iterate through all of them into a form. The website is built using ASP.NET Core 2.2 and Razor. How can I build a MemberExpression that asp-for TagHelper seems to expect using Reflection? I've read a couple of post about this on the Forum but none of the answer fits my need. The following snippet doesn't work. @model Foo; <h1>Foo Reflective filling example</h1> @foreach(var property in typeof(Foo).GetProperties()) { <p> <div

How to use asp-for TagHelper combined with Reflection

别等时光非礼了梦想. 提交于 2021-02-08 05:14:27
问题 I have a class Foo which contains a lot of properties, I'd like to iterate through all of them into a form. The website is built using ASP.NET Core 2.2 and Razor. How can I build a MemberExpression that asp-for TagHelper seems to expect using Reflection? I've read a couple of post about this on the Forum but none of the answer fits my need. The following snippet doesn't work. @model Foo; <h1>Foo Reflective filling example</h1> @foreach(var property in typeof(Foo).GetProperties()) { <p> <div

Asp.Net Mvc 5 image not displaying

风流意气都作罢 提交于 2021-02-07 20:02:19
问题 I have same images in Content and Views folders. I am trying to display images as below: <img src="~/Content/Images/download.png" alt="Content folder" /> <br /> <br /> <img src="~/Views/Home/download.png" alt="Views folder" /> <br /> The image in Content folder displays successfully but the one in Views folder doesn't display and gives below error: Failed to load resource: the server responded with a status of 404 (Not Found) But actually, the resource is there. Here are my folders: Could you