写了个提交帐号和密码的表单,并且提交完后点注册就跳转到另外一个页面,并且打印出帐号和密码。可是却打印不出来
,infor是实体类
代码如下:<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>addtext</title></head>
<body><%Html.BeginForm("addaction","Home",FormMethod.Get); %>
<div>
<ul><li>
<%=Html.TextBox("username")%>
</li>
<li>
<%=Html.Password("userpwd")%>
</li>
<li>
<input type="submit" value="注册" />
</li>
</ul></div>
<%Html.EndForm();%>
</body>
</html>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplication1.Models;namespace MvcApplication1.Controllers
{
[HandleError]
public class HomeController : Controller
{
public ActionResult Index()
{
ViewData["Message"] = "Welcome to ASP.NET MVC!"; return View();
} public ActionResult About()
{
return View();
}
public ActionResult addtext()
{
return View();
}
public ActionResult addaction()
{
string username=Request.Form["username"];
string pwd = Request.Form["userpwd"];
infor i = new infor();
i.username = username;
i.pwd = pwd;
ViewData["infor"] = i;
return View("addaction");
}
}
}
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="MvcApplication1.Models" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>addaction</title>
</head><%infor i = ViewData["infor"] as infor;%>
<body><%Html.BeginForm(); %>
<div>
<%=i.username%> <%=i.pwd%>
</div>
<%Html.EndForm(); %>
</body>
</html>
,infor是实体类
代码如下:<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>addtext</title></head>
<body><%Html.BeginForm("addaction","Home",FormMethod.Get); %>
<div>
<ul><li>
<%=Html.TextBox("username")%>
</li>
<li>
<%=Html.Password("userpwd")%>
</li>
<li>
<input type="submit" value="注册" />
</li>
</ul></div>
<%Html.EndForm();%>
</body>
</html>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplication1.Models;namespace MvcApplication1.Controllers
{
[HandleError]
public class HomeController : Controller
{
public ActionResult Index()
{
ViewData["Message"] = "Welcome to ASP.NET MVC!"; return View();
} public ActionResult About()
{
return View();
}
public ActionResult addtext()
{
return View();
}
public ActionResult addaction()
{
string username=Request.Form["username"];
string pwd = Request.Form["userpwd"];
infor i = new infor();
i.username = username;
i.pwd = pwd;
ViewData["infor"] = i;
return View("addaction");
}
}
}
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="MvcApplication1.Models" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>addaction</title>
</head><%infor i = ViewData["infor"] as infor;%>
<body><%Html.BeginForm(); %>
<div>
<%=i.username%> <%=i.pwd%>
</div>
<%Html.EndForm(); %>
</body>
</html>
解决方案 »
- 如何让TreeView不用每次点击或者展开都刷新啊?
- asp.net控件自动编码的问题
- 40分!web.config文件错误!在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错误的。
- xplog70.dll不存在,为什么还能恢复xp_cmdshell
- 相似性查询,有点难度.
- 怎么设计请给个思路:部门领导需要查阅所有下级部门的相关数据,这样的需求表结构怎么设计?
- c#asp.net WEB页中水晶报表数据显示正确,可是上面的图标按钮不能显示???
- 已知圆点的坐标,当从a点随意旋转一个角度后到b点,求b点的坐标
- 求iframe 用法帮助
- 高分汇报!!!部署服务的问题。
- 高手请出——asp.net中不长用到的运算符(|,&,^)
- 如何点击LinkButton 获取记录
<head><title>
addaction
</title></head>
<body><form action="/Home/addaction?username=AcceptVerbs&userpwd=AcceptVerbs" method="post">
<div>
</div>
</form>
</body>
</html>
可是却不打印
<head runat="server">
<title>addtext</title></head>
<body>
<%using(Html.BeginForm()){ %>
<div>
<ul><li>
<%=Html.TextBox("username")%>
</li>
<li>
<%=Html.Password("userpwd")%>
</li>
<li>
<input type="submit" value="注册" />
</li>
</ul></div>
<%}%>
</body>
</html>
{
string username=Request.Form["username"];
string pwd = Request.Form["userpwd"];
infor i = new infor();
i.username = username;
i.pwd = pwd;
ViewData["infor"] = i;
return View("addaction",i);
}
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="MvcApplication1.Models<infor>" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>addaction</title>
</head>
<body>
<div>
<%=Model.username%> <%=Model.pwd%>
</div>
</body>
</html>