I am having model as
public class GroupedIssueData
{
[Range(0, double.MaxValue, ErrorMessage = "Please enter valid number")]
public double IssueQty { get; set; }
public double ReqQty { get; set; }
public bool isSavings { get; set; }
}
This contains two properties as IssueQty and IsSaving, If the IsSaving is checked then IssueQty can be empty, If the IssueQty is not empty then IsSaving can be left blank. How can I validate this
My View is
<td>
@Html.DisplayFor(m => m.MaterialData[i].ReqQty)
@Html.HiddenFor(m => m.MaterialData[i].ReqQty)
</td>
<td>@Html.TextBoxFor(m => m.MaterialData[i].IssueQty, new { style = "width:70px" })@Html.ValidationMessageFor(m => m.MaterialData[i].IssueQty)</td>
<td class="text-center">@Html.CheckBoxFor(m => m.MaterialData[i].isSavings)</td>
And my Controller is
public async Task<ActionResult> GetWorkOrderMaterialDetails(IssueEntryModel m)
{
if (!ModelState.IsValid)
{
// redirect
}
var model = new IssueEntryModel();
}
How can I redirect to the if the Model is not valid. Do I need to redirect to same controller. I want to retain the entered data.
My View is