This question is locked. New answers and comments are not allowed.
I'm having some problems with binding.
When I use "EditorFor" for a field appears that is not held binding.
<%: Html.TextBoxFor (e => e.ModelObject.TextoRodape)%>
renders and displays correctly. In the post method, the value is correct.
<%: Html.Telerik (). EditorFor (e => e.ModelObject.TextoCorpo)%>
renders and displays correctly. In the post method, the value is a null string.
Model:
View
Control
Is there any way to perform the bind by hand?
Regards,
Roberto
When I use "EditorFor" for a field appears that is not held binding.
<%: Html.TextBoxFor (e => e.ModelObject.TextoRodape)%>
renders and displays correctly. In the post method, the value is correct.
<%: Html.Telerik (). EditorFor (e => e.ModelObject.TextoCorpo)%>
renders and displays correctly. In the post method, the value is a null string.
Model:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using Csla.Web.Mvc;using Documentos.Lib;namespace Documentos.Models{ public class OficioModeloViewModel : ViewModelBase<OficioModelo> { public Guid OficioModeloId { get { return ModelObject.Id; } set { ModelObject.Id = value; } } // OficioModelo is an CSLA object and resides on another project //default public OficioModeloViewModel() { ModelObject = OficioModelo.NewOficioModelo(); } //convenience public OficioModeloViewModel(Guid id) { ModelObject = OficioModelo.GetOficioModelo(id); } }}View
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Documentos.Models.OficioModeloViewModel>" %><asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Edit</asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Edit</h2> <% using (Html.BeginForm()) {%> <%: Html.ValidationSummary(true) %> <fieldset> <%: Html.Telerik().EditorFor(e => e.ModelObject.TextoCabecalho) .HtmlAttributes(new { style = "height:200px" }) %> <%:Html.Telerik().EditorFor(e => e.ModelObject.TextoCorpo)%> <%:Html.TextBoxFor(e => e.ModelObject.TextoRodape)%> <p> <input type="submit" value="Save" /> </p> </fieldset> <% } %> <div> <%: Html.ActionLink("Back to List", "Index") %> </div></asp:Content>Control
...//// GET: /OficioModelo/Edit/5 public ActionResult Edit(Guid id) { ViewData.Model = new OficioModeloViewModel(id); return View(); }//// POST: /OficioModelo/Edit/5 [HttpPost] public ActionResult Edit(Guid id, OficioModeloViewModel oficioModeloViewModel) { // when I use TextBoxFor, oficioModeloViewModel returns a filled object, // but when I use EditorFor, an empty object is returned... oficioModeloViewModel.OficioModeloId = id; if (SaveObject<OficioModelo>(oficioModeloViewModel.ModelObject, true)) return RedirectToAction("Index"); ViewData.Model = oficioModeloViewModel; return View(); }...Is there any way to perform the bind by hand?
Regards,
Roberto