在同一個頁面裡有多個form時,怎麼指定驗證的訊息要顯示在哪個form裡?
@using (Html.BeginForm("update1", "form1"))
{
if (Request.Form.AllKeys.Contains("btn1"))
{
@Html.ValidationSummary()
}
@Html.LabelFor(m => m.PointA1)
@Html.TextBoxFor(m => m.PointA1)
@Html.LabelFor(m => m.PointB1)
@Html.TextBoxFor(m => m.PointB1)
<br />
<input type="submit" name="btn1" value="確定" />
}
@using (Html.BeginForm("update2", "form2"))
{
if (Request.Form.AllKeys.Contains("btn2"))
{
@Html.ValidationSummary()
}
@Html.LabelFor(m => m.PointA2)
@Html.TextBoxFor(m => m.PointA2)
@Html.LabelFor(m => m.PointB2)
@Html.TextBoxFor(m => m.PointB2)
<br />
<input type="submit" name="btn2" value="確定" />
}
利用submit的name就好嘍!
沒有留言:
張貼留言