asp.net的mvc表单到控制器

时间:2023-02-03 23:37:05

asp.net的mvc开发表单提交代码:

 <% 
using(Html.BeginForm ("index","home",FormMethod.Post)){
%>
帐号:<%=Html .TextBox ("username")
%>
<br/>
密码:<%=Html .Password ("password")
%>
<br />
<input type="submit" value="登录"
/>
<%} %>

  public class helloController : Controller
{
//
// GET: /hello/
[HttpGet]
public ActionResult Index(int id,string name)
{
user u = new user();
u.id = 1;
u.name = "tom";
u.sex = true;
return View(u);
}
public class user
{
public int id{ set;get;}
public string name{set;get;}
public bool sex { get; set; }
}