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 8419341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:34:56+00:00 2026-06-10T02:34:56+00:00

I am relatively new to Web Parts and Web Forms (I have only worked

  • 0

I am relatively new to Web Parts and Web Forms (I have only worked a lot with the MVC framework).

I am planning to store some data in the control state. All the examples I can find put an object[] array in the control state and the base control state on the 0 index.

I don’t really like putting everything in an object[], so I wanted to create an extra class for my web part with typed properties: e.g. MyWebPartControlState. I will store the base control state in a property BaseControlState of type object.

I was wondering if this could cause any problems or if there are any other reasons why this might not be a good idea. I am wondering because it feels logical to me, but I cannot find any examples of control state where they don’t put everything in the control state directly or in a object[].

Thanks in advance.

  • 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-06-10T02:34:57+00:00Added an answer on June 10, 2026 at 2:34 am

    The control state is persisted in the same field as view state and follows the same rules for serialization. All the samples you found use an object array because that’s one of the types the optimized state serializer in ASP.NET understands and for which is able to optimize serialization.

    If you use a custom object the serializer won’t use the optimizations and instead will serialize your object using the BinaryFormatter which will lead to bloated control state. If you want to have a strongly typed view of your state you should implement IStateManager on your custom class so that it encapsulates the transformation of itself from and to simple objects that the serializer understands.

    If I recall correctly the serializer can efficiently serialize the following types:

    • Primitive types (int, long, etc);
    • DateTime;
    • string;
    • Boxed values of supported value types;
    • Object arrays containing instances of supported types;
    • Pair and Triplet objects containing instances of supported types.

    I wrote a short blogpost illustrating the differences in size resulting from a simple custom class being serialized with BinaryFormatter versus implementing IStateManager and decomposing to simple types that the serializer can optimize. You can find it at:

    ASP.NET ViewState Tips and Tricks #2

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

Sidebar

Related Questions

I am relatively new to ASP.NET programming, and web programming in general. We have
I'm relatively new to web programming. New to Javascript, PHP, Ajax, etc. I have
I'm relatively new to Perl, writing some XML parsing scripts. I have done two
I am relatively new to web development and web applications. I have heard about
I am relatively new to web development and learning all the time. I have
I'm relatively new to php development but not to web development in general. I
I'm very new to Web server matters, and relatively a naive student of C++.
Im relatively new to the Android world but I have a quick question. I
I'm building a custom web chat application, and while I have the basics worked
I am relatively new to web development, and I was hoping I could get

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.