Click here to Skip to main content
15,886,199 members
Articles / Programming Languages / C#

Cross Page Postback Without Circular Reference Errors

Rate me:
Please Sign up or sign in to vote.
4.11/5 (4 votes)
5 Jun 2008CPOL3 min read 41.7K   20  
Cross posting with strong typing.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/* note the reference to the Interface below */
public partial class Admin_y : System.Web.UI.Page, ICommonPostback 
{
    #region Cross page postback var
    private int iItemID = -1;
    private int iClientUploadID = -1;
    public int IItemID
    {
        get { return iItemID; }
        set { iItemID = value; }
    }
    public int IClientUploadID
    {
        get { return iClientUploadID; }
        set { iClientUploadID = value; }
    }
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        if (PreviousPage != null)
        {
            ICommonPostback frm = PreviousPage as ICommonPostback;
            Label2.Text = frm.IItemID.ToString();
        } 
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        iClientUploadID = 55;
        iItemID = 36;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
I specialize in stock charting systems built upon MS Sqlserver and Cold Fusion (DotNet 2.0 Versions next: to use SQL2005 and the CLR for data integration/de-normalization). My current project is an entire smart system based upon Point & Figure charting. This system includes Point & Figure Charts, Relative Strength Charts Ten-Week Charts, Bullish Percent Charts, Hi-Lo Charts. Reports include all standard summary information from all charts and additional “AI” reports revealing market opportunities. You want to see it? Email me.

I have a BS in Computer Science from SCSU
I’m a 10 year Cold Fusion Programmer, 10 year SQL Programmer, and a 1+ year DotNet Programmer. I have also written using C++, VB, Access, RPGII/III/400 (native code). I’m planning to recertify on sql2005, and get a 2.0 cert in asp.net.

And yes I do love dotnet….

Comments and Discussions