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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:56:31+00:00 2026-05-27T04:56:31+00:00

I have a question, and it may be because I’m not understanding the way

  • 0

I have a question, and it may be because I’m not understanding the way viewstate works. I have some code that sets a viewstate variable in the setter for a property in a custom control I have made.

 public bool EditMode
    {
        get { return (bool)(ViewState["editMode" + this.ID] ?? false); }
        set {ViewState["editMode" + this.ID] = value;} 
    }

The editmode is being set during a button click event.

 public void shippingButton_Click(object sender, EventArgs e) 
    {
        if (((Button)sender).CommandName== "Edit")
        {
            ctrlShippingAddress.EditMode = true;
        }
        else
        {
            Page.Validate();
            if (Page.IsValid)
            {
                ctrlShippingAddress.SaveAddress();
                ctrlShippingAddress.EditMode = false;
            }
        }
    }

I’ve tried manually setting it on page load in case I wasn’t adding this to the viewstate at the correct point in the page cycle, but as I understand it events occur before render. I have also tried adding ViewStateMode=”Enabled” to the control, then to the page using it, then to the master page with no luck.

If I debug at the point of the get/set I see that viewstate is an empty collection (which doesn’t make sense because it’s also saving form data that is persisting as it should).

I appreciate any help.

  • 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-27T04:56:32+00:00Added an answer on May 27, 2026 at 4:56 am

    After reviewing with a co-worker I discovered that the issue was in the pages node of the web.config

    <pages enableViewState="false"> 
    

    needed to be set to true

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

Sidebar

Related Questions

This question may not directly relate to programming. I have noticed that the technology
Okay the question title may not have made sense... mostly because I don't know
I have a question which may be somewhat silly because I'm pretty sure I
I have a question that may be quite naive, but I feel the need
My question may not make sense but I have valid reason. We use .net
I have an SQL question which may be basic to some but is confusing
This question may have been asked already - but unfortunately, I could not find
I realize that this question may have been asked several times in the past,
I'm still learning c++ and have a question that may be obvious, or maybe
The title of this Question may not be accurate because I wasn't sure how

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.