c# - Html.BeginForm() not rendering properly -


while searching in stackoverflow other questions didn't helped in situation. how possible debug such error 1 html.beginform not rendered page.

i use code

@model extremeproduction.models.selectusergroupsviewmodel  @{ viewbag.title = "user groups"; }  <h2>groups user @html.displayfor(model => model.username)</h2> <hr />  @using (html.beginform("usergroups", "account", formmethod.post, new { enctype = "multipart/form-data", id = "usergroupsform" })) {     @html.antiforgerytoken()     <div class="form-horizontal">         @html.validationsummary(true)         <div class="form-group">             <div class="col-md-10">                 @html.hiddenfor(model => model.username)             </div>         </div>         <h4>select group assignments</h4>         <br />         <hr />         <table>             <tr>                 <th>                     select                 </th>                 <th>                     group                 </th>             </tr>             @html.editorfor(model => model.groups)         </table>         <br />         <hr />         <div class="form-group">             <div class="col-md-offset-2 col-md-10">                 <input type="submit" value="save" class="btn btn-default" />             </div>         </div>     </div> } <div>     @html.actionlink("back list", "index") </div> 

edit: added model

    // wrapper selectgroupeditorviewmodel select user group membership:     public class selectusergroupsviewmodel     {         public string username { get; set; }         public string firstname { get; set; }         public string lastname { get; set; }         public list<selectgroupeditorviewmodel> groups { get; set; }          public selectusergroupsviewmodel()         {             this.groups = new list<selectgroupeditorviewmodel>();         }          public selectusergroupsviewmodel(applicationuser user)             : this()         {             this.username = user.username;             this.firstname = user.firstname;             this.lastname = user.lastname;              var db = new applicationdbcontext();              // add available groups public list:             var allgroups = db.groups;             foreach (var role in allgroups)             {                 // editorviewmodel used editor template:                 var rvm = new selectgroupeditorviewmodel(role);                 this.groups.add(rvm);             }              // set selected property true user member:             foreach (var group in user.groups)             {                 var checkuserrole =                     this.groups.find(r => r.groupname == group.group.name);                 checkuserrole.selected = true;             }         }     }       // used display single role group checkbox, within list structure:     public class selectgroupeditorviewmodel     {         public selectgroupeditorviewmodel() { }         public selectgroupeditorviewmodel(group group)         {             this.groupname = group.name;             this.groupid = group.id;         }          public bool selected { get; set; }          [required]         public int groupid { get; set; }         public string groupname { get; set; }     }  public class group     {         public group()         {         }           public group(string name)             : this()         {             roles = new list<applicationrolegroup>();             name = name;         }           [key]         [required]         public virtual int id { get; set; }          public virtual string name { get; set; }         public virtual icollection<applicationrolegroup> roles { get; set; }     } 

**** edit ****

and form

my current form.

http://i834.photobucket.com/albums/zz268/gtas/formmine_zpsf6470e02.png

i should receive form 1 copied code this

how should copied tutorial

http://i834.photobucket.com/albums/zz268/gtas/formcopied_zpsdb2f129e.png

any ideas or how source of evil makes life hard time now?

you haven't defined editor groups, line @html.editorfor(model => model.groups) tries find editor render property, , uses default one, doesn't want.

you either need define editor template knows how render property, or need use loop render inside page.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -