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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:43:43+00:00 2026-06-17T21:43:43+00:00

I have composite web server control, which at the moment doesn’t perform any actions.

  • 0

I have composite web server control, which at the moment doesn’t perform any actions. My aim is to place inside it child controls beginning with checkbox. I try to do it in the following way:

[DefaultProperty("Text")]
[ToolboxData("<{0}:SubmitImageControl runat=\"server\"></{0}:SubmitImageControl>")]
public class SubmitImageControl : CompositeControl
{
    private CheckBox _checkBox;

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
    }

    protected override void CreateChildControls()
    {
        _checkBox = new CheckBox();
        Controls.Add(_checkBox);
        base.CreateChildControls();
    }
    protected override void RenderContents(HtmlTextWriter output)
    {
        _checkBox.RenderControl(output);
    }
}

Registering and placing on the page:

<%@ Register TagPrefix="uc" Namespace="PostBackHandlerApp.Controls" Assembly="PostBackHandlerApp" %>
<uc:SubmitImageControl runat="server" />

Checkbox appears on the page and everything seems fine until we look at the view state. Its value is

/wEPDwULLTExMTg2MzM0NjJkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBR1jdGwwMCRNYWluQ29udGVudCRjdGwwMCRjdGwwMD+PWeqrbtVyQSNMxvfjcmJkKAwpIuEPWJd+m5W6eJtQ

Then, if we simply remove the code Controls.Add(_checkBox);, view state size reduces greatly:

/wEPDwULLTExMTg2MzM0NjJkZLrri0oSGPS9ZiOTsRtSageoskXzCME4KCdRZxOiJyR9

If I move the code of child initialization and adding to OnInit method of my control (where, as far as I know, view state tracing is still disabled), result stays the same. Also, this MSDN article recommends to perform initialization only in CreateChildControls method:

You should create the child controls in the CreateChildControls method and not in OnInit or another life cycle phase. The server control architecture relies on calls to CreateChildControls whenever the Controls collection is needed, such as during data binding (if applicable).

Could anyone explain me why view state becomes larger? 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-17T21:43:44+00:00Added an answer on June 17, 2026 at 9:43 pm

    The reason why viewstate is populated is implementing IPostBackDataHandler interface by large part of data controls, including checkbox. Interface’s method LoadPostData is called automatically after the LoadViewState event and viewstate gets populated from the posted data.
    Here is nice article about it.

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

Sidebar

Related Questions

I have a composite control which emits HTML that looks like this <span id=myControl>
Let's say we have a composite web control with a combobox and a textbox.
I have composite project which contains: C++ library for Linux/Windows, C++/CLI library based on
I have a composite drop down calendar user control that consists of a textbox
I'm writing a set of C# composite web server controls for displaying dialog boxes.
In our project, we have 20 simple web controls, 8 composite web controls including
I'm building a WCF web service which returns a composite object that looks similar
I wrote a composite web control that is used in several web applications. If
Alright, this is a little bit complicated. I have a composite control that contains
Are there any open source asp.net web applications which are using backbone.js and preferably

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.