我的目的很简单:
在一个页面输入条件然后在同一页的下面把数据库中的记录显示出来!我给个代码
control代码为:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(string Tcode)
{
var bookacc = _bookacc.Get_cc_bookAcc_subject(Tcode);
return View(bookacc);
}
index页面代码为:
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication1.Models.cc_bookAcc_subject>" %>
<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">
Home Page
</asp:Content>
<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
<h2>选择科目代码:</h2>
<%=Html.ValidationSummary("出错了,请检查!") %>
<% using (Html.BeginForm()) { %>
<fieldset style="text-align:center">
<p>
<label for="Tcode">科目代码:
<%=Html.TextBox("Tcode")%>
<%=Html.ValidationMessage("Tcode", "*")%>
</label>
</p>
<p>
<input type="submit" value="查询"/>
</p>
</fieldset>
<% } %>
<%=Model.TName %>//注意这里提示错误
<p>
To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.
</p>
</asp:Content>
以上代码不知道哪里出错了!