Handle two html helpers for same property

52 views Asked by At

I am currently having two html helpers written for same property in my razor view. first one is hidden and second one is visible.

Why I am having two controls is based on some business rules I will return text else html control.

The issue I am facing now is when I get a control back and user updates value in it, then its saving the value fine. But if he tries to save null, then its saving value from the hidden field. I am not able to figure out a workaround for this.

by the way I am using form submit and toObject to save the controls value

My html looks like below

<div style="display: none;">
    @Html.EditorFor(O => O.Prop)
</div>
<div>
    @Html.CustomHelper(O => O.prop)
</div>

Please help me with some work around.......

0

There are 0 answers