Last post Dec 13, 2017 06:00 AM by Edward Z
Dec 12, 2017 09:28 AM|mrsadin|LINK
I am working on edit page, i have a table like this :
Id, Title, ImageAddress
int, string, string
all are required.
I upload image in a folder and save its address in ImageAddress field.
So i have an action : Edit
now i have 2 options:
1- just editing title
2- edit title and ImageAddress
I am confused in first option, when user changes Title input and click on submit button how can i edit just Title? You know ModelState.IsValid will not allow me to set FileInput empty!
what is best solution?
Dec 12, 2017 03:14 PM|bruce (sqlwork.com)|LINK
Dec 12, 2017 05:46 PM|sadin|LINK
You mean in view model I should not set file required and in action check if file input is filled then update imageaddress and if it does not fill just update title and leave imageaddress as it is?
Dec 13, 2017 06:00 AM|Edward Z|LINK
>> I am confused in first option, when user changes Title input and click on submit button how can i edit just Title? You know ModelState.IsValid will not allow me to set FileInput empty!
Did you edit in MVC view or web api controller?
If in MVC View, while creating a new record, it will fill image address field, and when turning to edit view, the image address will also contain value, it would not be empty. And then, it will not cause ModelState.IsValid false even if
you only edit title field.
Could you share us front end which is used for edit?
If you are not return image address from database to front end, you could follow the suggestion from bruce, and it will not break by ModelState.IsValid. You could update image address if there is value.