Hi nad:
Very good investigative work :)
Let me clarify:
With EnableViewState=false the TextBox control can't remember the
value it saw on the previous postback, however the TextBox control
will know what it's initial value was (either an empty string or the
string in the Text attribute of <asp:TextBox>), and what the incoming
form value is.
Without ViewState, the control will raise the TextChanged on every
postback if the incoming text value is different than the initial
value (the initial value being the Text property set in <asp:TextBox>,
or an empty string if the Text attribute doesn't exist).
With ViewState on, the control will only raise TextChanged if the text
has changed since the previous postback.
Does that make more sense? I know you have a form to experiment with,
but here is another simple example you can use to see the difference.
<%@ Page language="c#" %>
<script runat="server">
private void Button1_Click(object sender, EventArgs e)
{
Response.Write("Button1_Click fired<br>");
}
private void TextBox1_TextChanged(object sender, EventArgs e)
{
Response.Write("TextChanged fired<br>");
}
</script>
<HTML>
<body>
<form id="Form1" method="post" runat="server">
<asp:TextBox Text="foo"
id="TextBox1"
runat="server"
EnableViewState="false"
OnTextChanged="TextBox1_TextChanged"
/>
<asp:Button id="Button1"
runat="server"
Text="Button"
OnClick="Button1_Click"
/>
</form>
</body>
</HTML>
On Tue, 5 Jul 2005 11:49:01 -0700, Nad <Na*@discussions.microsoft.com>
wrote:
Scott,
I put a breakpoint inside TextChanged event of a TextBox control and
regardless of EnableViewState's value the debugger stops there when I change
the text.
If I didn't misunderstand you, wouldn't this invalidate what you said?
--
Scott
http://www.OdeToCode.com/blogs/scott/