Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6000307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:40:29+00:00 2026-05-23T00:40:29+00:00

In my ASP.NET 4.0 website, which uses master pages, I’ve disabled viewstate sitewide in

  • 0

In my ASP.NET 4.0 website, which uses master pages, I’ve disabled viewstate sitewide in web.config:

<pages enableViewState="false" />

and am trying to enable it only when absolutely necessary.

I’ve run into an issue with a DropDownList control (no databinding going on, just hardcoded items):

    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged" Width="150px" ViewStateMode="Enabled" EnableViewState="True">
        <asp:ListItem>Chocolate</asp:ListItem>
        <asp:ListItem>Strawberry</asp:ListItem>
        <asp:ListItem>Vanilla</asp:ListItem>
    </asp:DropDownList>

Even though I’ve enabled view state for this particular control, there’s a problem with selecting the first item:

enter image description here

    protected void DropDownList1_SelectedIndexChanged (object sender, EventArgs e)
    {
        TextBox1.Text = (sender as DropDownList).SelectedValue;
    }

The expected result is that whenever “Chocolate” is selected TextBox1 will display “Chocolate”. But what I’m seeing is that TextBox1 only changes when Strawberry or Vanilla is selected. In the example above I selected Strawberry and then Chocolate.

In other words, the DropDownList SelectedIndexChanged isn’t firing when the first item is selected, but is firing when the second or third is selected.

Here are the property settings for the DropDownList:

enter image description here

I tried the same code starting from a blank project and the page works as expected. (Selecting the first item does fire the event).

Thanks in advance for any suggestions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:40:30+00:00Added an answer on May 23, 2026 at 12:40 am

    It appears you can’t set <pages enableViewState="false" /> in the web.config or in any page directives for the ViewStateMode property to work.

    Basically EnableViewState=false will override any and all ViewStateMode settings.

    There doesn’t appear to be a way to set the ViewStateMode property in the web.config at this point so it looks like you’ll have to remove any EnableViewState properties from your application and set the ViewStateMode property to Disabled in all of your page directives.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Silverlight web app which uses ASP.net Website administration tool for user
I have an asp.net mvc website which of course has a web.config file. I
I am working on an ASP.NET website which uses forms authentication with a custom
I have an ASP.Net website which uses a MySQL database for the back end.
I have developed a website using Asp.Net MVC which uses a SQL CE database
I have a website built in asp.net mvc 3 which uses the repository pattern
I have an ASP.Net 4.0 website which uses SQL Server CE and EF code-first
I have an asp.net application which uses the web part framework to allow users
I have an asp.net web-from application which uses ASP.NET membership provider . Beside this
I've got an ASP .NET website which uses Forms authentication to secure certain parts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.