本帖最后由 崔增阳 于 2014-1-20 13:18 编辑
c#代码里的txtName和txtRemark为什么拿不到值呢?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
<form action="Default2.aspx" method="POST">
<input type="hidden" name="hiddenVierState" value="<%=txtViewStateValue %>"/>
姓名:<input type="text" name="txtName" value="<%=txtName %>"/><br/>
密码:<input type="text" name="txtRemark" value="<%=txtRemark %>"/><br/>
<input type="submit" value="提交"/>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
public string txtName;
public string txtRemark;
public string txtViewStateValue;
protected void Page_Load(object sender, EventArgs e)
{
txtName = Request.Form["txtName"];
txtViewStateValue = txtName;
txtRemark = Request["txtRemark"];
if (Request["hiddenVierState"]!=null)
{
if (Request["txtName"]==(Request["hiddenVierState"]))
{
Response.Write("没有改变");
}
else
{
Response.Write("改变了");
}
}
}
}
|