Skip to main content

Pass Values Between ASP.NET Web Pages without Session or any State Management

If the source page and target page are both ASP.NET Web pages in the same Web application, and if you transfer execution from the source page to the target page on the server by using the transfer method, the target page can access public properties in the source page.

Page One

<asp:TextBox ID="textCity" runat="server" Text="Brjesh"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

 public String CurrentCity
        {
            get
            {
                return textCity.Text;
            }
        }

        public List<String> Current
        {
            get
            {
                return _Current;
            }
        }
        private List<String> _Current = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            _Current = new List<String>();
            _Current.Add("1");
            _Current.Add("2");
            _Current.Add("3");
            _Current.Add("4");
            _Current.Add("5");


        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Server.Transfer("PageTwo.aspx");
        }


Page Two

<%@ PreviousPageType VirtualPath="~/PageOne.aspx" %> 

        public string strName { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            strName = PreviousPage.CurrentCity;
            List<String> Current = PreviousPage.Current;
        }
 

Comments

Popular posts from this blog

Tata Punch: A Compact SUV That Packs a Punch

crystal reports using stored procedures in asp.net

  crystal reports using stored procedures in asp.net   ReportDocument document = new ReportDocument ();         document.Load( this .Page.Server.MapPath( "~/CRY/crTest.rpt" ));         string str = ConfigurationManager .AppSettings[ "ConnectionString" ];         string server = str.Substring(str.IndexOf( "=" ) + 1, str.IndexOf( ";" ) - (str.IndexOf( "=" ) + 1));         str = str.Substring(str.IndexOf( ";" ) + 1);         string database = str.Substring(str.IndexOf( "=" ) + 1, str.IndexOf( ";" ) - (str.IndexOf( "=" ) + 1));         str = str.Substring(str.IndexOf( ";" ) + 1);         string user = str.Substring(str.IndexOf( "=" ) + 1, str.IndexOf( ";" ) - (str.IndexOf( "=" ) + 1));        ...

Encryption Decryption Helper

Encryption Decryption Helper public class clsEncryptionDecryption { #region Variable Declaration private static string keyString = " keyString "; #endregion #region Methods/Functions /// <summary> /// Get Encrpted Value of Passed value /// </summary> /// <param name="value"></param> /// <returns></returns> /// <remarks></remarks> public static string GetEncrypt( string value) { return Encrypt(keyString, value); } /// <summary> /// Get Decrypted value of passed encrypted string /// </summary> /// <param name="value"></param> /// <returns></returns> /// <remarks></remarks> public static string ...