c# - 2 input but validate only one -
could me problem? assume had form table of stuff (products example), possibility of add new product , edit existing product. requirement have add row visible. have problem when, click on 'edit' product, have 2 inputs( 1 edit , 1 add ). when posted form server choosing save editable row, wanted validate edit row , nothing add row (which empty while).
and problem default mvc validation applied on add row inputs, controls become red, , property validation message appear. don't want see them, because confusing. can't understand why happens. possibly because mvc can not cast empty string decimal (the type in viewmodel input refered)
you need 2 different forms, 1 add project , 1 edit project. these need point different actions, validate 1 object.
im not sure code looks suggest more following, views separated entirely:
start view displays of 'products' or whatever data is. when populate in view, can assign edit
links each individual one. need 1 overall add project
link. so:
@html.actionlink("add project", "addprojectview") each project in model.projects @html.actionlink("edit", "editview", new {.id = project.projectid}) @<div>propertyname: @project.property</div> next
now can have edit
view separated data view, can handle validation on own. likewise, add project
view separated , handles own validation. upon successful add or edit, can redirect user above view, data displayed , updated.
Comments
Post a Comment