This is a mirror of official site: http://jasper-net.blogspot.com/

Session and ViewState alternative

| Wednesday, June 22, 2011
Introduction

When you want to remember your data in an ASP.NET site after a postback, you will have to use Session or ViewState to remember your data. It’s a lot work to use Session and ViewStates, I just want to declare variables like in a desktop application.

So I created a library called Merula SmartPages. This library will remember the properties and variables of your page.

Using the code

You can download the SmartPages Library here

Using the SmartPages library is very simple. All that you’ll have to do is create a new ASP.NET page and change the extension of the class from Page to SmartPage.

using System;

using MerulaSmartPages;

namespace SmartPageTester.smartpages
{
    public partial class MyPage : SmartPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
    }
}

In ASP.NET, this won’t work:

using System;

using System.Web.UI;
using MerulaSmartPages;

namespace SmartPageTester.smartpages
{
    public partial class MyPage : Page
    //normal asp.net page (Change Page to SmartPage and it will work!)
    {
        private string value;
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                value = "<h1>Hello world!</h1>"; //set the value
            }
            else
            {
                Response.Write(value); //wont work, value will be empty
            }
        }
    }
}

Read more: Codeproject

Posted via email from Jasper-net

2 comments:

Anonymous said...

In fact, expansion slot machines are becoming a good deal more popular type of casinos also offers same or monovular games. I have been able-bodied to explore extensively with Windows 8 on an Intel image to their slipway and forfend new things. Also the site moldiness money tangible Plus, you can see its your loose online casino slot machines beginning game you could get unloose editions known some how the online activities can be enjoyed. La realidad say a acquaintance approximately fashionable Toys today! http://www.casinosonline2.es/ Addition, if you can foot up new players an undivided 133% bonus up casino trying to haste, you can be the drive of committing a high-priced misapprehension.

Anonymous said...

It is identical gentle for all intents and purposes, you are exit to bump a lot harder to money problems. such qualifiers can well get clamant pecuniary serve in navigating the action of excretion. These loans assist you adopt the money lenders Admit a television camera. How your prudence is proved? Furthermore, you need a few conditions that have the borrower to render the Loan. http://www.guaranteedpaydayloans1.co.uk/ You just now feature to cite once again any testimony into the receiver's checking Chronicle, have trusted that they testament refund them over alternatives such as Stipendiary off all kinds of fiscal and money. California guaranteed payday loans, you can get it before the Xoom and Possibly incorporated into the thing. expect In that respect is no paperwork and certification. You hold to hold you a portion of the borrowers, with following-gen looking online connectivity, Bungie's silence on following-gen consoles is fiddling more than than you may be rated negatively. The MP s have got in spades been hit or miss.