页面中有两种形式,一种用于搜索,另一种用于删除....
<table><tr><td>
<% using(Html.BeginForm("ViewList","ControllerName",
[values],FormMethod.Post,new{id="viewListForm"}))
{ %>
Name: <%=Html.TextBox("Name", "[value]", new { maxlength = "250" })%>
Location: <%=Html.TextBox("Location", "[Value]", new { maxlength = "250" })%>
<input type="submit" id="Search" name="Search" value="Search" />
<% } %>
</td></tr>
<tr><td>
<% using(Html.BeginForm("DeleteList","ControllerName",
new { name=?,location=? },[values],FormMethod.Post,
new{id="deleteListForm"}))
{ %>
[here the code for all items displayed in a table.]
<input type="submit" id="Delete" name="Delete" value="Delete" />
When delete buttom pressed i need to pass two parameters ie name
and location. The values of name and location are in the above viewListForm.
How i take this value from the viewListForm at run time ?
<% } %>
</td></tr><table>
答案 0 :(得分:0)
使用javascript填充隐藏的输入。
或使用javascript动态更改搜索表单的操作。
或者例如在jQuery中动态创建表单并提交它。
答案 1 :(得分:0)
您需要有一个控制器操作,将FormCollection作为参数
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ActionName(FormCollection collection)
{
// you can pull key value pair from the posted collection
string formValue = collection["InputId"]
}