我正在尝试构建一个简单的 ASP.net MVC 应用程序。
我的控制器如下所示。
namespace CustomerReadAndLoad.Controllers
{
public class CustomerController : Controller
{
//
// GET: /Customer/
public ActionResult Index()
{
return View();
}
public ActionResult LoadCustomer()
{
return View();
}
[HttpPost]
public ActionResult DisplayCustomer()
{
Customer obj = new Customer();
obj.ID = Convert.ToInt16(Request.Form["CuatomerID"]);
obj.Name = Convert.ToString(Request.Form["CuatomerName"]);
obj.Amount = Convert.ToInt16(Request.Form["CuatomerAmount"]);
return View(obj);
}
}
}
我试图在 LoadCustomerView 中包含动作 DisplayCustomer,如下所示
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<!DOCTYPE html>
<html>
<head runat="server">
<meta name="viewport" content="width=device-width" />
<title>LoadCustomer</title>
</head>
<body>
<div>
<form action ="DisplayCustomer" method ="post">
Welcome to Customer management System<br />
Enter the below details <br />
Customer ID :- <input type="text" name = "CuatomerID" /><br />
Customer Name :- <input type="text" name = "CuatomerName" /><br />
Customer Amount :- <input type="text" name = "CuatomerAmount" /><br />
<input type ="button" value="ClickHere" />
</form>
</div>
单击提交按钮后,我无法移动到视图 DisplayCustomer。