我有一个如下所示的文本框
@using (Html.BeginForm("checkUserType", "Place", new {type = }))
{
<div id="login">
<div class="userNameLabel">UserName</div>
<div class="userNameField"><input type="text" id="txtUserName"/><span><input type="button" value="ok" id="ok" /></span></div>
</div>
}
我想将文本框值传递给我的 Controller 。为此,我使用了下面的代码,但它不起作用...... 请帮忙...
操作方法
[HttpPost]
public ActionResult checkUserType(string type)
{
var elements = from element in db.USERS
where element.UserType == type
select element;
if (elements == null)
{
return RedirectToAction("Index");
}
else
{
return RedirectToAction("Place/Index");
}
}
最佳答案
尝试一次
window.location.href = '@Url.Action( "checkUserType", "Place" )?type='+type
关于javascript - 如何将文本框值传递给 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17485434/