TextBox COntrol et ViewState

  • Thread starter Thread starter fabrice
  • Start date Start date
F

fabrice

Hi,

I have a trouble with my TextBox Control and it's ViewState in my form...
The property for it, is FALSE as following :

<form id="frmSearchBre4" runat="Server">

<asp:textbox id="myID" TabIndex="1" EnableViewState="false" MaxLength="50"
runat="server" TextMode="SingleLine">
</asp:textbox>

<asp:ListBox Width="200" Font-Size="10" Font-Name="Arial" id="myid2"
rows="4" Enabled="true"
EnableViewState="false" runat="server">
</asp:ListBox>

</form>


In my web.config :

<pages buffer="true"
enableSessionState="true"
enableViewStateMac="true"
validateRequest="true"
autoEventWireup="true">
</pages>


But when the page is a "postbak" the value of th TextBox control is
maintained. Not in the listBox control (it's right)...I don't know why...
Have you got an explanation ?

Thanks a lot
fabrice
 
the textbox uses viewstate to store the previous value so it can fire the
text changed event, whether its set enabled/disabled or visible. if you
turn off viewstate it has no way to know these values, but the browser posts
back the current value, so thats always maintained.

the list box has a list of values which it needs regenerate on postback for
to set the selected item based on the postback value. these are stored in
the viewstate. if you run the listbox withour viewstate you must reload the
valuelist in your code in OnInit (before the process postback data event).
otherwise when it gets the postback data, there is no item to select.

-- bruce (sqlwork.com)
 
thanks

Bruce Barker said:
the textbox uses viewstate to store the previous value so it can fire the
text changed event, whether its set enabled/disabled or visible. if you
turn off viewstate it has no way to know these values, but the browser
posts back the current value, so thats always maintained.

the list box has a list of values which it needs regenerate on postback
for to set the selected item based on the postback value. these are stored
in the viewstate. if you run the listbox withour viewstate you must reload
the valuelist in your code in OnInit (before the process postback data
event). otherwise when it gets the postback data, there is no item to
select.

-- bruce (sqlwork.com)
 
Back
Top