日期:2014-05-19  浏览次数:20516 次

关于ViewState的一个很奇怪的问题。
将以下代码的EnableViewState设成False了,但是单击按钮之后,textbox中还有原来的内容。IE   6.0   ,   Firefox   1.5,   Opera,   Netscape   7.2下均存在回显的情况。
如果EnableViewState= "true ",文本框下存在原来的数据我可以理解,但是EnableViewState= "false "实在无法理解了。。。而且,两种情况下跟踪的情况下看是正常的。。。
实在不得其解。。。
请各位高手帮忙解惑!


<!--Default.asp-->
<%@   Page   Language= "C# "   AutoEventWireup= "true "     CodeFile= "Default.aspx.cs "   Inherits= "_Default "     EnableViewState= "false "%>

<!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> 无标题页 </title>
</head>
<body>
        <form   id= "form1 "   runat= "server ">
        <div>
                <asp:TextBox   ID= "TextBox1 "   runat= "server "> </asp:TextBox>
                <asp:Button   ID= "Button1 "   runat= "server "   OnClick= "Button1_Click "   Text= "Button "   />
                <asp:Label   ID= "Label1 "   runat= "server "   Text= "Label "> </asp:Label> </div>
        </form>
</body>
</html>


<!--Default.aspx.cs-->
using   System;
using   System.Data;
using   System.Configuration;
using   System.Web;
using   System.Web.Security;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.WebControls.WebParts;
using   System.Web.UI.HtmlControls;

public   partial   class   _Default   :   System.Web.UI.Page  
{
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {

        }
        protected   void   Button1_Click(object   sender,   EventArgs   e)
        {
                Label1.Text   =   TextBox1.Text;
        }
}


------解决方案--------------------
尽管你屏蔽了ViewState,但是,TextBox是表单数据,是通过NameValueCollection 得到哦的