updatemodel

MVC EF - Update navigation property

旧城冷巷雨未停 提交于 2019-12-12 02:22:57
问题 You can see my database diagram below. Post.cs public partial class Post { public Post() { this.PostImages = new HashSet<PostImage>(); this.PostMappings = new HashSet<PostMapping>(); } public int ID { get; set; } public string Title { get; set; } public string TitleMenu { get; set; } public string Preview { get; set; } public string Content { get; set; } public Nullable<bool> Visible { get; set; } public Nullable<int> Display { get; set; } public Nullable<System.DateTime> DateAdded { get; set

ASP.NET MVC Issue with Using Reflection Created Objects with the Default Model Binder

人走茶凉 提交于 2019-12-11 05:34:36
问题 I am having a weird issue in ASP.NET MVC with objects not being updated with UpdateModel when passed a formCollection . UpdateModel does not appear to be working properly when the object being updated is created through reflection. Scenario: I have an application which has approximately 50 lookup tables--each of which includes exactly the same schema including typical fields like id, title, description, isactive, and createdon. Rather than build 50 views, I wanted to have a single view which

Model Binding - Type in External Assembly

此生再无相见时 提交于 2019-12-11 01:19:06
问题 I have a type in an assembly which isn't referenced by the core library but is referenced from the web application. e.g. namespace MyApp.Models { public class LatestPosts { public int NumPosts { get; set; } } } Now i have the following code in the core library: [HttpPost, ValidateAntiForgeryToken] public ActionResult NewWidget(FormCollection collection) { var activator = Activator.CreateInstance("AssemblyName", "MyApp.Models.LatestPosts"); var latestPosts = activator.Unwrap(); // Try and

MVC UpdateModel ComplexType

大城市里の小女人 提交于 2019-12-06 05:09:02
问题 If you have the following type. public class Person { public string FirstName { get; set; } public string LastName { get; set; } public List<TheParameters> Parameters { get; set; } public Address Address { get; set; } } public class Address { public string Street { get; set; } public string City { get; set; } public string State { get; set; } } public class TheParameters { public string Parameter { get; set; } } You make your page stronglytyped to Person. "System.Web.Mvc.ViewPage<Person>"

ASP.NET MVC 2 UpdateModel() is not updating values in memory or database

a 夏天 提交于 2019-12-06 04:37:58
I am new to MVC, and so am working through the NerdDinner tutorial, here . In particular, I'm running into problems with the use of the UpdateModel method, which is explained in the part five of that tutorial. The problem is, when I try to edit the value of a dinner object using the UpdateModel method, the values do not get updated, and no exceptions are thrown. Oddly, I am not having any trouble with the Create or Delete features that are illustrated in the tutorial. Only the update feature isn't working. Below, I have included the Controller code that I am using, as well as the view markup,

p:selectOneMenu does not set value in bean

纵饮孤独 提交于 2019-12-04 17:45:42
问题 Quick question. This hasn't happened to me before when working with SelectOneMenu. This is my code. <h:outputLabel for="listaRegiones" value="Región: " /> <p:selectOneMenu id="listaRegiones" value="#{nuevaProvincia.regionSelect}" required="true"> <f:selectItems value="#{nuevaProvincia.regiones}" /> </p:selectOneMenu> <p:message for="listaRegiones" /> And this is my backing bean. @ManagedBean(name="nuevaProvincia") @ViewScoped public class nuevaProvincia implements Serializable { public static

MVC UpdateModel when the names don't match up

会有一股神秘感。 提交于 2019-12-04 13:56:29
问题 Let's say that you have a Model that looks kind of like this: public class MyClass { public string Name { get; set; } public DateTime MyDate { get; set; } } The default edit template that Visual Studio gives you is a plain textbox for the MyDate property. This is all fine and good, but let's say that you need to split that up into it's Month/Day/Year components, and your form looks like: <label for="MyDate">Date:</label> <%= Html.TextBox("MyDate-Month", Model.MyDate.Month) %> <%= Html.TextBox

MVC UpdateModel ComplexType

孤街浪徒 提交于 2019-12-04 11:21:53
If you have the following type. public class Person { public string FirstName { get; set; } public string LastName { get; set; } public List<TheParameters> Parameters { get; set; } public Address Address { get; set; } } public class Address { public string Street { get; set; } public string City { get; set; } public string State { get; set; } } public class TheParameters { public string Parameter { get; set; } } You make your page stronglytyped to Person. "System.Web.Mvc.ViewPage<Person>" <form action="/Home/Save" method="post"> <b>Your Name</b> <label for="FirstName"> <span>First Name</span>

p:selectOneMenu does not set value in bean

雨燕双飞 提交于 2019-12-03 10:42:24
Quick question. This hasn't happened to me before when working with SelectOneMenu. This is my code. <h:outputLabel for="listaRegiones" value="Región: " /> <p:selectOneMenu id="listaRegiones" value="#{nuevaProvincia.regionSelect}" required="true"> <f:selectItems value="#{nuevaProvincia.regiones}" /> </p:selectOneMenu> <p:message for="listaRegiones" /> And this is my backing bean. @ManagedBean(name="nuevaProvincia") @ViewScoped public class nuevaProvincia implements Serializable { public static final long serialVersionUID = 1L; public nuevaProvincia() throws DAOException { this.provincia = new

MVC UpdateModel when the names don't match up

不打扰是莪最后的温柔 提交于 2019-12-03 08:51:13
Let's say that you have a Model that looks kind of like this: public class MyClass { public string Name { get; set; } public DateTime MyDate { get; set; } } The default edit template that Visual Studio gives you is a plain textbox for the MyDate property. This is all fine and good, but let's say that you need to split that up into it's Month/Day/Year components, and your form looks like: <label for="MyDate">Date:</label> <%= Html.TextBox("MyDate-Month", Model.MyDate.Month) %> <%= Html.TextBox("MyDate-Day", Model.MyDate.Day) %> <%= Html.TextBox("MyDate-Year", Model.MyDate.Year) %> When this is