我在表单上有两个类似的表单块:
<form action="/2/All/Home/SubIdeaComment?SubIdeaID=5576&referrerUrl=http%3A%2F%2Flocalhost%3A1261%2F2%2FAll%2FHome%2FIdea%2F5575%3FreferrerUrl%3Dhttp%253A%252F%252Flocalhost%253A1261%252F2" method="post">
<textarea id="SubComment" name="SubComment" style="width: 80%"></textarea>
<br />
<input type="submit" class="InputBtn" value="Reply" />
<input type="reset" class="InputBtn" onclick="ShowHideReply($('#divSubIdeaReply5576'), $('#subIdeaButtons5576'))"
value="Cancel" />
<br />
<br />
</form>
和
<form action="/2/All/Home/SubIdeaComment?SubIdeaID=5577&referrerUrl=http%3A%2F%2Flocalhost%3A1261%2F2%2FAll%2FHome%2FIdea%2F5575%3FreferrerUrl%3Dhttp%253A%252F%252Flocalhost%253A1261%252F2" method="post">
<textarea id="SubComment" name="SubComment" style="width: 80%"></textarea>
<br />
<input type="submit" class="InputBtn" value="Reply" />
<input type="reset" class="InputBtn" onclick="ShowHideReply($('#divSubIdeaReply5577'), $('#subIdeaButtons5577'))"
value="Cancel" />
<br />
<br />
</form>
我需要调用相同的控制器方法(MVC项目):
[AcceptVerbs(HttpVerbs.Post)]
[ValidateInput(false)]
public ActionResult SubIdeaComment(int SubIdeaID, string SubComment, string referrerUrl)
{
if (User.Identity.IsAuthenticated && !String.IsNullOrWhiteSpace(SubComment))
_repository.AddComment(User.Identity.Name, SubIdeaID, null, SubComment);
return Redirect(referrerUrl);
}
但是当第一个表单提交时 - 我将SubComment设为空。据我了解,原因是2个字段具有相同的名称。但是有不同的形式....如何正确地做到这一点?