locked
C# objects with ViewState - Am I following a standard practice? RRS feed

  • Question

  • User-1419977730 posted

    Hi guys,

    Background:

    I'm building a web program requiring many C# objects.

    To avoid as many possible problems with ViewState as I can, I have decided to work to a basic principle which is:

    I will let my Default.aspx.cs class know about only one of my custom C# objects, this is so that:

    - I only have to store one custom C# object in ViewState from Default.aspx.cs (the other custom C# objects will be created through this main one's constructor).

    - This one custom C# object can then do all the communication with the other objects. Default.aspx.cs will communicate only to this one.

    All is working, so far & so good.

    Nub of my question:

    In order to keep to the principle of only needing my Default.aspx.cs to know of one object, I intend to store all conditional values needed by Default.aspx.cs to run the program in that seperate, custom C# object.

    i.e.

    (Within Default.aspx.cs)

    if(myMainC#Object.KeyBoolValue)
    {
    Run the program;
    }
    else
    {
    Program over - Display message;
    }

    I wondered if this was standard, sensible practice? My reason for wanting to be sure is that it's code I'm writing to show to potential employers ;)

    Thanks, as always,

    Dan :)

    Saturday, January 19, 2013 4:45 AM

Answers

  • User614805505 posted

    Hi,

    If Viewstate is your concern, then you should go for ASP.NET MVC.

    Because, It does not use view state or server-based forms. This makes the MVC framework ideal for developers who want full control over the behavior of an application.

    http://msdn.microsoft.com/en-us/library/dd381412(v=vs.108).aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 23, 2013 9:39 AM