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

  • SEARCH
  • Home
  • 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 226957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:33:31+00:00 2026-05-11T19:33:31+00:00

EDIT 2: Well, I went to the code. Note what they are doing here.

  • 0

EDIT 2: Well, I went to the code. Note what they are doing here. They are saying load viewstate, and then turning around and setting the Text property to what was in the viewstate. After LoadViewState is called though viewstate tracking is on, and that results in the behavior I’m seeing. I think what the code should say is:

if (s != Text) {Text = s;}. That would get rid of the issue altogether and keep whatever invariant they need in place.

/// <internalonly/>
        /// <devdoc>
        ///    <para>Load previously saved state.
        ///       Overridden to synchronize Text property with LiteralContent.</para> 
        /// </devdoc>
        protected override void LoadViewState(object savedState) { 
            if (savedState != null) { 
                base.LoadViewState(savedState);
                string s = (string)ViewState["Text"]; 
                if (s != null)
                    Text = s;
            }
        } 

Edit: From all my tests this appears to only affect the Label control. I still think this is a bug.

This is an ASP.NET 3.5 Website.

Consider the following .aspx page:
(html, head, body, etc. snipped)

<form id="form1" runat="server">
        <asp:Label runat="server" ID="label1">
            This is a lot of text. 
            This is a lot of text. 
            This is a lot of text. 
            This is a lot of text. 
            This is a lot of text. 
            This is a lot of text. 
            This is a lot of text.             
        </asp:Label>
        <asp:Button runat="server" ID="button1" Text="Click" OnClick="button1_Click" />
        <script>
            document.write(document.getElementById("__VIEWSTATE").value.length);
        </script>
    </form>

The page has the following code behind:

protected void button1_Click(object sender, EventArgs e) {
        //label1.AccessKey = "a";
    }

Yes, that line is commented out. Coming to that. So, when you click the button you will see that viewstate is 52 bytes. Even though the label has lots of text, of course the way viewstate works is that it doesn’t need to save the lots of text in the viewstate because the initial value of the Text property never changed. OK. So far so good. This is all expected behavior. In fact, even if the label contained 1 meg of text, the viewstate size would still be 52 bytes. OK. Now change the method to

protected void button1_Click(object sender, EventArgs e) {
        label1.AccessKey = "a";
    }

It doesn’t matter what property we change. Now click the button. ViewState size goes up to 92 bytes. Alright 40 bytes to store a one character access key, a little much if you ask me but whatever 🙂 Now, click the button again. What’s the viewstate size now? Should be 92 bytes right? No. It’s 480. Clicking anymore and it stays at the 480 bytes size. What’s happening? Changing the label property caused the label to start storing the label TEXT in the viewstate. What???? Stick a 100K of text in the label and you’ll see the viewstate go up to ~100K.

Is this a bug? How is this possibly expected behavior?

  • 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-11T19:33:31+00:00Added an answer on May 11, 2026 at 7:33 pm

    Yes. It’s a bug in the Label control.

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

Sidebar

Ask A Question

Stats

  • Questions 105k
  • Answers 105k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Probably because of the wildcard, IIS sends the request to… May 11, 2026 at 8:43 pm
  • Editorial Team
    Editorial Team added an answer I think you need to use a Unicode string with… May 11, 2026 at 8:43 pm
  • Editorial Team
    Editorial Team added an answer If you want to reference files from the foo/package1/resources folder… May 11, 2026 at 8:43 pm

Related Questions

The "goto" statement comes straight out of ASM or any other assembler language. Here's
Today is officially my first day with C++ :P I've downloaded Visual C++ 2005
Fixed: See notes at bottom I am implementing a generic class that supports two
I need to knock out a quick animation in C#/Windows Forms for a Halloween
So I am being taught assembly and we have an assignment which is to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.