Give the submit button a unique name on both your forms, like so:
@using (Html.BeginForm())
{
@Html.ValidationSummary()
@Html.Label("code", "Confirmation Code")
@Html.TextBox("code")
<input type="submit" name="login-top" value="Go" />
}
@using (Html.BeginForm("SendConfirmation", "Auth"))
{
@Html.ValidationSummary()
@Html.Label("email", "Email")
@Html.TextBox("email")
<input type="submit" name="login-main" value="Resend" />
}
Then you can check whether a particular form has been submitted by checking the value of the request for the key that corresponds to the submit button and then conditionally display the validation summary ie. in the top form you would add:
if (Request.Form.AllKeys.Contains("login-top"))
{
@Html.ValidationSummary()
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…