Hi folks,
how do i do the following, with an ASP.NET MVC UpdateModel? I'm trying to read in a space delimeted textbox data (exactly like the TAGS textbox in a new StackOverflow question, such as this) into the model.
eg.
<input type="Tags" type="text" id="Tags" name="Tags"/>
...
public class Question
{
public string Title { get;...
I have been working my way through Scott Guthrie's excellent post on ASP.NET MVC Beta 1. In it he shows the improvements made to the UpdateModel method and how they improve unit testing. I have recreated a similar project however anytime I run a UnitTest that contains a call to UpdateModel I receive an ArgumentNullException naming the ...
I have an edit page to edit some info. the page fills a complex object. one of the properties of this object is a generic list.
If I just edit information and save, updatemodel works fine. if i remove (I do this using jquery to remove the form elements client side) something from the list the updatemodel fails with an "object not set to...
i have my checkbox for a bool field like so in my view:
=Html.CheckBox("Active", ViewData["Active"] != null ? ViewData["Active"] : (ViewData.Model.Active != null ? ViewData.Model.Active : false)
you can forget the fluff if you like:
=Html.CheckBox("Active", ViewData.Model.Active)
..causes the same problem.
when i try to update my mo...
Hi everyone,
I am trying to use UpdateModel in a class other than my controller and it doesn't work.
When I call UpdateModel in my controller class it works perfectly. The references are the same in both classes.
Would someone please help me out on this? Thanks!
...
I am in the process of writing some unit tests for my controllers in RC1. Here is the
controller's public signature I'm testing:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult AcceptColleague()
{
The implementation inside the AcceptColleague uses the TryUpdateModel(colleague) method of populating the Colleague obje...
I have a custom object called S2kBool that can be converted to and from a regular Boolean object. Basically, it allows my application to treat boolean values in my legacy database the same way it treats C# booleans. Then problem is, when I attempt to use a check box to set the value of an S2kBool property, it fails.
Code like this works...
Hi,
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; ...
I want to use the updateModel in a controller that has no notice of the type of the view.
I have different views that have different types but all have an ExternalBase class as inherited type.
So in my controller I always have a ExternalBase but the controller doesn't know the correct type.
On saving I call a method that gets the co...
Continuing from this question, I've got a form with all the Vehicles listed for a Person, the vehicle fields are editable, and they are now successfully posting back to my Save action.
Now I'd like to use UpdateModel to save the data, but I'm not sure how to construct it. Here's my Save action right now:
<ActionName("Edit"), AcceptVerb...
a) At the moment I have a deployed app on live on asp.mvc beta ... but few days ago it refuses to work with following error:
Method not found: 'System.String System.Web.Mvc.Html.LinkExtensions.RouteLink(System.Web.Mvc.HtmlHelper, System.String, System.Web.Routing.RouteValueDictionary, System.Web.Routing.RouteValueDictionary)'.
Version ...
I'm unsure if this has been asked before but here goes.
I have an MVC application with the HTML looking like this;
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<EnvironmentalVandals.Controllers.MonthlyItemsFormViewModel>" %>
I have in the controller the following;
[...
Hello,
I have class named Product
public class Product
{
public virtual int Id { get; set; }
public virtual Category Category { get; set; }
}
Please tell me how to update Category with UpdateModel method.
Below you'll find category code in View
<%= Html.DropDownList("Category", (System.Web.Mvc.SelectList) ViewData["categor...
Ok - I have two tables in the database, employees and companies. Here are the basic schemas for each
Table Companies
CompanyID - GUID - PK
CompanyName - NVarChar(100)
Other Descriptive Fields....
Table Employees
EmployeeID - GUID - PK
CompanyID - GUID - FK
Employee Descriptive Fields...
So now I have a one to many relationship as ea...
I'm using Linq to SQL within an ASP.NET MVC application. The model consists of a Decisions table with a foreign key link to an Options table (one decision, many options). So the Model allows me to access the Options collection through the Decision.Options property. I want to allow my users to update the Options collection for a Decisio...
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 ...
Has anybody had luck with this?
Please let me know if I understand it correctly, if I have a simple model let's say with:
public string Name { get; set; }
public string Details { get; set; }
public DateTime? Created { get; set; }
and then I perform a:
var myModel = getCurrentModelFromDb(id);
UpdateModel(myModel, "ModelName", new str...
Hello,
I wondered whether UpdateModel is considered an "expensive" operation (due to Reflection lookup of the model properties), especially when seen in the context of a larger web application (think StackOverflow)?
I don't want to engage in premature optimization but I consider it a design choice to use UpdateModel which is why I'd lik...
I'm not sure if this is a bug in the DefaultModelBinder class or what.
But UpdateModel usually doesn't change any values of the model except the ones it found a match for.
Take a look at the following:
[AcceptVerbs(HttpVerbs.Post)]
public ViewResult Edit(List<int> Ids)
{
// Load list of persons from the database
List<Person> peo...
I am interested to know what you guys feel should be deemed "correct behaviour" in terms of the UpdateModel method in ASP.NET MVC.
The reason I ask here is perhaps if this functionality is "by design" somebody could clarify as to why it is the way it is, and perhaps a way to call it differently to achieve desired functionality, which I ...