Take the example classes below. I want to display the customer and two addresses (from a LIST) on a form. Does the model binder in MVC beta support this or will I have to write my own custom binder?
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
public List<Address> Addre...
Firstly, bear with me here. I have a custom model binder which is successfully mapping form data to a custom object. Within this model binder it also maps form items to different custom object. What I feel I should be able to do is create a separate model binder to take care of this second mapping. This is a simplified version.
Custom o...
Hi all.
I've got the following action:
public ActionResult Create()
{
var entity = new Employee();
TryUpdateModel(entity, new[] { "Person.Name", "Code", "CompanyID" });
if (ModelState.IsValid)
{
var result = Service.MergeEmployee(entity);
return RedirectToAction("List", new { success = true });
}
return...
I seem to have a problem with getting MVC to fill in my custom model parameter when called through GET instead of POST.
I have a JavaScript snippet that calls into an action like so:
$.getJSON('<%= Url.Action("DoSearch") %>' + location.search,
function(data) {
if (data.Result == "OK") {
location.href = location....
Hey all, I'm facing a really strange problem that has me smoked.
I have a fairly simple scenario where I have a strongly typed view that is correctly populated from the controller on the GET, but then when it POSTS the form to the controller, the Reqeust is full of all the right values and right key names for the default model binder ...
Hi All
I am trying to understand how associated entities are updated when using custom modelbinders.
If you have a Product entity with a relationship to a Category entity and you are displaying a list of category choice for a product in a dropdown on a form.
The the user assigns a new category and that change needs to be persisted wit...
Hi,
I'm having some trouble binding to a nested list with the default binder. I am using linq to sql and have the following data structure
Competition < CompetitionQuestions < CompetitionQuestionChoices
my html is as follows
<%= Html.Hidden("Competition.Id",Model.Competition.Id) %>
<%=Html.TextBox("Competition.CompetitionName", Mod...
I have problem with model binding in my ASP.NET MVC 2 RC application that uses NHibernate for data access. We are trying to build the application in a Ruby on Rails way and have a very simple architecture where the domain entities are used all the way from the database to the view.
The application has a couple of domain entities which c...
Hey all.
First of all some context:
I have a form, where I post back some objects that are automatically materialized into objects by MVCs built-in ModelBinder:
<input type="hidden" name="myobj[0].Id" />
<input type="text" name="myobj[0].Hours" />
<input type="hidden" name="myobj[1].Id" />
<input type="text" name="myobj[1].Hours" />
...
Hi,
I'm 3 days into learning MVC for a new project and i've managed to stumble my way over the multitude of issues I've come across - mainly about something as simple as moving data to a view and back into the controller in a type-safe (and manageable) manner. This is the latest.
I've seen this reported before but nothing advised has s...
I created a Website(it is poco object) model binder, that checks the sessions:
public class WebsitesModelBinder:IModelBinder
{
private const string websitesSessionName = "SelectedSite";
#region IModelBinder Members
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
...
I have a TypeConverter on the base class in my project.
[TypeConverter(typeof(CodeTypeConverter))]
abstract class CodeBase
I have a number of classes which inherit this base
class TitleCode : CodeBase
class PreferenceCode : CodeBase
When the thing that calls the type converter (ValueProvider.ConvertSimpleType) it does not create a ...