ViewState Code

Posted on 2011-10-04
Last Modified: 2012-05-12
I have the following code in an aspx page and I'm not sure what it's doing.

if (ViewState["COOLEnabled"].ToString().ToUpper() == "YES")
            ddlSFCOOL.Enabled = bEnabled;
            ddlSFCOOL.Enabled = false;

any help will be appreciated.

Question by:TimSweet220
    LVL 17

    Accepted Solution

    Hello, somewhere your page must be setting that viewstate value:
    ViewState["COOLEnabled"] = "yes";

    Open in new window

    Then in another place of your page that code (your example) check for that value to decide enable/disable your ddlSFCOOL control.

    The ViewState object is like your Session object, but it values dont reside in the server, instead these values are saved in your page, this mean that they dont expires when your session does.

    Author Comment

    Thanks.  I have a follow up question that I'll create a new question for.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now