-3
我有以下看法裏面放:哪些參數需要一個Html.BeginForm()
<h2>enter the student name to search</h2>
@using (Html.BeginForm())
{
<label>Search:</label>
<input type="text" name="searchString" />
<input type="submit" name="submit" />
}
和視圖對應於以下控制器
namespace Searching.Controllers
{
public class SearchController : Controller
//somecode
[HttpPost]
public ActionResult SearchIndex(FormCollection formCollection)
{
string searchString=formCollection["searchString"];
var search = from m in db.Searches select m;
if (!String.IsNullOrEmpty(searchString))
{
search = search.Where(s => s.Name.Contains(searchString));
}
return View(search);
}
}
}
控制器名稱是SearchController .cs和要傳遞的方法的名稱是SearchIndex。 Html.BeginForm()中的參數應該是什麼,我是一個begginer。
非常感謝你,它正在 –
沒問題。但你絕對應該多讀一點關於ASP.NET MVC的內容...... – Dante
我同意,你可不要只是用Google搜索。 'Html.BeginForm示例' – Doomsknight