0
我有形式2類似的形式,塊:2文本框在2形式具有相同名稱
<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個字段具有相同的名稱。但有不同的形式....如何正確地做到這一點?
但這是形式的獨特,是不夠的? – 2011-06-16 11:30:07
不幸的是,它對於整個文檔必須是唯一的。 – 2011-06-16 11:31:12
剛剛看到ASP.NET模板 - 它生成內部具有相同ID的元素 – 2011-06-17 20:49:49