asp.net-mvc-5

How to Insert to Master-detail tables in ASP.NET MVC 5

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-13 18:08:23
问题 I have Orders table and OrderDetails table in DB. With Entity Framework 6 I have obtained a model so I have classes generated from it. I also generated controllers and views from the Orders table. Orders folio (PK) date customer (FK) OrdersDetail folio (FK) -- to the Orders table product (FK) price quantity The generated Create Post action is the following: [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "folio,date,customer")] Orders order) { if (ModelState

Get all Area, Controller and Action as a tree

廉价感情. 提交于 2020-01-13 16:43:32
问题 I need to get all areas that has been registered as list and all of their controllers as a sub list and the same thing for actions. something like this: AdminArea HomeController Index Add ... OtherController ... AnotherArea HomeController Index ... ... I have checked the answer of this question, and this one, but they are not what i'm looking for. The first one return all the routes that has been registered and the second one return all controllers at once. Update Ok, with the below code i

How to set properties in a custom WebViewPage?

白昼怎懂夜的黑 提交于 2020-01-13 14:54:29
问题 I have a very basic custom WebViewPage class in which I want to assign a value to a custom property. Here's my code: public abstract class WebViewPage : System.Web.Mvc.WebViewPage { public Employee UserPrincipal { get; set; } public override void Execute() { // Controller is also a custom class that contains the same property which is injected by // a custom ActionFilterAttribute. I've confirmed that the attribute is correctly updating // the property. Controller controller = (this

validating date format not working

☆樱花仙子☆ 提交于 2020-01-13 11:26:26
问题 I'm having problem with date validation. In my View, I have a jQuery datepicker - I changed the format from yy/mm/dd to mm/dd/yy and now I get client-side validation errors. For example, The value '02/25/2014' is not valid for Date of Birth. The Javascript: $('#DateOfBirth').datepicker({ changeMonth: true, changeYear: true, dateFormat: "mm/dd/yy", yearRange: "-90:-5" }); The View Model: [Required] [Display(Name = "Date of Birth")] public DateTime? DateOfBirth { get; set; } The View: @Html

EF Core with ASP MVC .NET 4.6

橙三吉。 提交于 2020-01-13 09:17:06
问题 In a project I need to set up an ASP.NET MVC (with .NET 4.6.1) but using the "new" EF Core for accessing the database. Unfortunately every documentation explains only how to setup an ASP.NET Core MVC project. I just gave it a try and when it comes to creating the database via the Package Manager Console I get the error message: No parameterless constructor was found on 'DataContext'. Either add a parameterless constructor to 'DataContext' or add an implementation of 'IDbContextFactory' in the

AspNet.Identity Custom User and Custom Role should be simple; what am I missing?

偶尔善良 提交于 2020-01-13 03:53:09
问题 Using examples from http://www.asp.net/identity I've gotten this far. The RoleManager works flawlessly and I treat the UserManager the same. I think everything is correct, but I can't seem to new up a UserManager correctly in a controller. What is wrong? At one point, I was successfully getting the UserManager to work but was getting an EntityValidationError saying "Id is required" when creating a new user with UserManager.Create(user, password); as posted in this question UserManager.Create

EF6 + Postgres relation dbo.AspNetUsers does not exist

北城以北 提交于 2020-01-12 19:45:09
问题 I have been following this post on using PostgreSQL with EF6 http://www.jasoncavett.com/blog/postgresql-and-entity-framework-6-code-first/. I have started a brand new MVC5 project hoping to use Postgres in my application for backend. The application starts up fine however when you go to register a user (I selected individual authentication) I get the following error messsage ERROR: 42P01: relation "public.AspNetUsers" does not exist I am unsure as to how to resolve this problem. The error

EF6 + Postgres relation dbo.AspNetUsers does not exist

雨燕双飞 提交于 2020-01-12 19:44:40
问题 I have been following this post on using PostgreSQL with EF6 http://www.jasoncavett.com/blog/postgresql-and-entity-framework-6-code-first/. I have started a brand new MVC5 project hoping to use Postgres in my application for backend. The application starts up fine however when you go to register a user (I selected individual authentication) I get the following error messsage ERROR: 42P01: relation "public.AspNetUsers" does not exist I am unsure as to how to resolve this problem. The error

Why is Ajax.ActionLink updating entire page instead of just UpdateTarget

北战南征 提交于 2020-01-12 14:22:58
问题 This should replace just the UpdateTarget, but it does not, it replaces the entire page and I don't see why. The correct partial view is being returned, but instead of replacing the target id, it is replacing the entire page. <div id="magHeader"> <p>this is a test.</p> @Ajax.ActionLink("Edit", "GetEditor", "Home", new AjaxOptions(){ UpdateTargetId = "magHeader", InsertionMode = InsertionMode.Replace}) </div> At runtime, the link looks like this: <a href="/Home/GetEditor" data-ajax-update="

Why is Ajax.ActionLink updating entire page instead of just UpdateTarget

£可爱£侵袭症+ 提交于 2020-01-12 14:22:42
问题 This should replace just the UpdateTarget, but it does not, it replaces the entire page and I don't see why. The correct partial view is being returned, but instead of replacing the target id, it is replacing the entire page. <div id="magHeader"> <p>this is a test.</p> @Ajax.ActionLink("Edit", "GetEditor", "Home", new AjaxOptions(){ UpdateTargetId = "magHeader", InsertionMode = InsertionMode.Replace}) </div> At runtime, the link looks like this: <a href="/Home/GetEditor" data-ajax-update="