Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

im very new to mvc, lest say i have a viewmodel that cotains objects like

public class vm_set_rol
{
    public IEnumerable<SelectListItem> roles { get; set; }
    public Rol_User rol { get; set; }

}

rol is an object like:

public class Rol_User
{
    public int idUser { get; set; }
    public int Role { get; set; }
    public int GrantedBy { get; set; }
    public bool canGrant { get; set; }
    public DateTime ExpirationDate { get; set; }
}

so i have a form on a view to let the user select 1 role from a roles dropdown and select a date and a checkbox somthing like:

      <div class="ModalContainer">
        @using (Ajax.BeginForm(new AjaxOptions
                                        {
                                            UpdateTargetId = "gestionRolContainer",
                                            Url = "Permiso/Test",                                               
                                            InsertionMode = InsertionMode.Replace,
                                            HttpMethod = "POST",



                                        }
                                )
                )
        { 
            <fieldset>
                    <legend>@Res_String.RolLabel</legend>

                    <span>ROL:</span><br />@Html.DropDownListFor(m => m.rol, Model.roles, new {@id="AdmPermUserRolesDropDown" })
                    <br />

                    @Html.CheckBoxFor(m => m.rol.conceder ,Model.rol.conceder) <span>Delegate?</span>
                    <br />

                    <input type="submit" class="buttonClass" value="OK" />
            </fieldset>


        }
</div>

the problem is that i only get null values, if i create some other property on the model like a string or int, those are posted back ok,

i kind of understad why objects are not posted back, bust is there any workaround??? or put a object on the modes is just wrong and i shuld declare the propertis on the viewmodel instead of an object???

share

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.