TextBox COntrol et ViewState

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
 
B

Bruce Barker

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)
 
F

Fabrice

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top