EnableViewState not being set to false

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to post a form and not have the form maintain it's value. I am have tried setting EnableViewState = False at the control and on Page Load. When I submit the button my selection is returned. What am I missin

Mik


<asp:DropDownList id="DropDownList1" style="Z-INDEX: 101; LEFT: 115px; POSITION: absolute; TOP: 163px" runat="server" Width="154px" Height="67px" EnableViewState="False"><asp:ListItem>Item 1</asp:ListItem><asp:ListItem>Item 2</asp:ListItem><asp:ListItem>Item 3</asp:ListItem><asp:ListItem>Item 4</asp:ListItem></asp:DropDownList>
 
That's not it. I am not using the controls listed. I was using a listbox. If I don't set it to run at server then it works fine. Is this by design? I am new to dotnet and I am trying to get a handle on when to use what controls

Thanks for your reply

Mike
 
Hi,

in fact it is, ListBox just isn't listed because it uses both 'worlds' in
fact. It stores all items to ViewState, but posts the selection along with
the form (despite do you have ViewState enabled or not).

To reset the selection, you need to set SelectedIndex manually to -1 or call
ClearSelection() method of ListBox.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke



Mike Drewery said:
That's not it. I am not using the controls listed. I was using a
listbox. If I don't set it to run at server then it works fine. Is this by
design? I am new to dotnet and I am trying to get a handle on when to use
what controls.
 
This doesn't clear it

DropDownList1.ClearSelection(
DropDownList1.SelectedIndex = (-1

in page on load

Thank
Mike
 
Back
Top