如何避免ASP.NET中的TextChanged事件

如何避免ASP.NET中的TextChanged事件,asp.net,textbox,viewstate,textchanged,Asp.net,Textbox,Viewstate,Textchanged,我有一个文本框和一个回发按钮 <asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged1" EnableViewState="false"></asp:TextBox><span></span> <asp:Button ID="Button1" runat="server" Text="Button" /> 但我不知道在文本未更改

我有一个文本框和一个回发按钮

<asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged1"     EnableViewState="false"></asp:TextBox><span></span>
<asp:Button ID="Button1" runat="server" Text="Button" />

但我不知道在文本未更改时该怎么办,也不知道如何不触发事件。

问题在于禁用ViewState时从TextBox保存值。将其保存在HiddenField中不是一个好主意,因为我们可以在页面加载时从HiddenField中获取值,但我们需要在TextBox init中获取值。然而,如果我们将文本框保存到会话变量,这个问题就会消失。代码如下:

protected void TextBox1_TextChanged1(object sender, EventArgs e) {
    Session["text"] = TextBox1.Text;
}
protected void TextBox1_Init(object sender, EventArgs e) {
    if(Session["text"]!=null)TextBox1.Text = Session["text"].ToString();
}

在textchanged事件上保存会话变量中的值,并在textbox init上还原它。比较在框架级别上运行。

如何从db加载文本框?如何加载文本框?嗯。。。我想它是在页面加载事件之后加载的。对不起,我还是有点困惑,你能告诉我你到底需要什么吗?我需要禁用ViewState的TextBox表现得像启用了一样,即仅当文本更改时才触发TextChanged事件(现在它触发每次回发)。我无法取消订阅此活动或打开ViewState。
protected void TextBox1_TextChanged1(object sender, EventArgs e) {
    Session["text"] = TextBox1.Text;
}
protected void TextBox1_Init(object sender, EventArgs e) {
    if(Session["text"]!=null)TextBox1.Text = Session["text"].ToString();
}