locked
Public Partial Classes RRS feed

  • Question

  • User-200615377 posted
     

    Hello Everyone,

    How to access these public partial classes:

    I have something like this

    public partial class test : System.Web.UI.Page

    {

    // What ever I need here

    }

    I have a second class

    public partial class test1 : System.Web.UI.Page

    {

    //Code here

    How can I access class test from here ??

    }

    Thursday, December 28, 2006 8:31 PM

Answers

  • User-1323204926 posted

    hi,

    are you refering the partial classes in two pages?

    if so , you want to access the value in one page from another page, am I right?

    try this

    public partial class Default4 : System.Web.UI.Page
    {
        private string _myValue;
        public string myValue
        {
            get
            {
                return _myValue;
            }
            set
            {
                _myValue = value;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
                 
        }

        protected void Button1_Click1(object sender, EventArgs e)
        {
            myValue = "hellow Default2.aspx";
            Server.Transfer("Default2.aspx");
        }
    }

    public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
         
           Response.Write(PreviousPage.myValue);
         }
       }

    btw, add <%@ PreviousPageType VirtualPath="~/Default4.aspx" %> to the html

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 29, 2006 1:33 AM