EnableViewState not being set to false

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>
 
G

Guest

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
 
T

Teemu Keiski

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.
 
G

Guest

This doesn't clear it

DropDownList1.ClearSelection(
DropDownList1.SelectedIndex = (-1

in page on load

Thank
Mike
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top