asp.net-mvc-5

Set a hardcoded value in a HiddenFor within a for-loop

大城市里の小女人 提交于 2019-12-13 07:58:14
问题 When there is only one person to select I still need to assign the hardcoded value 'TRUE' to the People[i].IsSelected property to satisfy my validation. How can I do that? @if (hasMoreThanOnePerson) { <td> @Html.CheckBoxFor(m => m.People[i].IsSelected) </td> } else { @Html.HiddenFor(m => m.People[i].IsSelected, true) // Set TRUE always to hidden field within for loop with indexer } 回答1: Use htmlAttributes to set value property of Hidden Field using this overload or this overload: @Html

Adding additional query to return(View)

偶尔善良 提交于 2019-12-13 07:57:02
问题 I have a ViewModel and I currently return a query where if the movie has employees and they have a role then that movie, actor(s), and role(s) are all returned. Now I want to add an additional query to this that makes a string (or whatever works best) of all the employees within the same movie. So if three people were in the same movie, I want a list of them so that I can call it in my View. My current query/ Controller is var parameter = Int32.Parse(Filter); var queryString = from m in db

How to make a variable in the razor view global? [closed]

南楼画角 提交于 2019-12-13 07:55:28
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I want to know how to make a variable that I declare in a razor view global so that I can access it in another view? I performed an ajax function that fetches the location of a td element in its parent table. I then stored the index in an int variable. Now I want to access that

NuGet not working properly with Asp5-Mvc6

可紊 提交于 2019-12-13 07:37:18
问题 When restoring packages in the new xproj project types, there are the new package config in the project.json : "dependencies": { "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final", "Microsoft.AspNet.Authentication.Facebook": "1.0.0-rc1-final", "Microsoft.AspNet.Authentication.Google": "1.0.0-rc1-final", .... } Nuget restores theese with no problem. When the .xproj depends on normal .proj files, you sometimes needs to create wrappers, and write the dependency like this: "frameworks":

Jquery click doesn't work twice

别说谁变了你拦得住时间么 提交于 2019-12-13 07:27:15
问题 I'm trying to write CRUD operations using ajax. Here some code: These are my View classes: //PhotoSummary @model PhotoAlbum.WEB.Models.PhotoViewModel <div class="well"> <h3> <strong>@Model.Name</strong> <span class="pull-right label label-primary">@Model.AverageRaiting.ToString("# stars")</span> </h3> <span class="lead">@Model.Description</span> @Html.DialogFormLink("Update", Url.Action("UpdatePhoto", new {photoId = @Model.PhotoId}), "Update Photo", @Model.PhotoId.ToString(), Url.Action(

Paging with 3 sub-queries with 1 connection vs 2 Queries with 2 connections

六月ゝ 毕业季﹏ 提交于 2019-12-13 07:22:54
问题 I have been doing a lot of research on Paging and I am stuck between two methods. With both approaches I will be using PagedList.MVC to display my pages, however the problem lies in how do I pass the data to the PagedList and which of my two methods is more efficient. The best example I have found out there is as follows: public static PagedList<Customer> GetPagedCustomers(int skip, int take) { using (var context = new AdventureWorksLTEntities()) { var query = context.Customers.Include(

Javascript variable storing Garbage instead of value entered into <input> box?

北城余情 提交于 2019-12-13 07:15:24
问题 I am attempting to use jQuery/AJAX/JSON in order to pass a value from an <input> on my main INV_Assets.Edit() View to my MVC5 controller method createNewModel() . There, the value is to be added to the database table INV_Models , and on successful return I want to refresh my dropdownlist so that it includes the new value. However, when I run my current code (below) the value for alert(test) is coming up as garbage with RKW5IcXyLzel7mYJ7qqPMvrKIG8_wVv7obAJPx0NzRwgZ23QI

ASP.NET 5 and Angular Routing not working on dnx rc1

最后都变了- 提交于 2019-12-13 07:15:12
问题 Hi I have a project built in ASP.NET 5 (dnxcore50 and dnx451). It is serving the requests for my AngularJS scripts. When I built the project I was using the Microsoft beta 5 dependencies and using a rewrite rule to send all the requests to index.html and so my angular routing would work just fine. But today I had to upgrade to the rc1 dependencies and now my rewrite is not working and I'm just getting a 404 on my route. This new libraries added this weird lines of code to my web.config

How to track what adds a 'DefaultConnection' connection string to web.config of my MVC app

假如想象 提交于 2019-12-13 06:52:00
问题 I have a weird problem - I have noticed that after web deployment of my MVC app, a new connection string is added to web.config file. <add name="DefaultConnection" connectionString="DefaultConnection_ConnectionString" providerName="System.Data.SqlClient" /> I have no idea where it comes from, something adds it automatically. Here is my web.config file after publishing <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="entityFramework" type="System.Data

Populate a mvc5 list?

旧巷老猫 提交于 2019-12-13 06:33:59
问题 Right now I can create games under the Games/Create. And I can make a post under Post/Create. But my problem is that right now my public int GameId { get; set; } gets populated with the items that is in my Game table in my SQL database. Which is just fine that's how I like it. But I want public string Title { get; set; } to the populated the same way with the values that are in the Game database. public int GameId { get; set; } gets populated with a dropdownlist with the values that is in my