下面是我的查看页面。<form>
当我插入值时没有标签,它完美地插入。但是当我用<form>
标签插入未插入的值时,调试点指向[HttpGet]
而不是[HttpPost]
. 出于验证目的,我已插入<form>
标签。但这似乎没有用..告诉我解决方案....
@model CustMaster.Models.MyAccount
@using CustMaster.Models
@{
ViewBag.Title = "Customer Information";
}
<html>
<head>
<title>Customer Information</title>
<link href="../../style.css" rel="stylesheet">
</head>
<body>
<form action="" id="contact-form" class="form-horizontal">
@using (Html.BeginForm())
{
<table>
<tr>
<td><h3>User Information</h3></td>
</tr>
</table>
<table>
<tr>
<td>
<div class="control-group">
@Html.LabelFor(model => model.CustomerFirstName,
new { @class = "control-label" })
<div class="controls">
@Html.TextBoxFor(model => model.CustomerFirstName,
new { @class = "input-xlarge" })
</div>
</div>
</td>
<td>
<div class="control-group">
@Html.LabelFor(model => model.CustomerMiddleName,
new { @class = "control-label" })
<div class="controls">
@Html.TextBoxFor(model => model.CustomerMiddleName,
new { @class = "input-xlarge" })
</div>
</div>
</td>
</tr>
</table>
<button type="submit">Register</button>
}
@*</form>*@
<script type="text/javascript" src="../../assets/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../../assets/js/jquery.validate.js"></script>
<script type="text/javascript" src="../../assets/js/jquery.validate.min.js"></script>
<script type="text/javascript" src="../../script.js"></script>
</body>
</html>
下面是我的控制器
[HttpGet]
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(MyAccount myacc)
{
MyAccount ma = new MyAccount();
var objview = ma.GetCustInfo(myacc);
return View();
}