Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Accessing the properties of a page


Message #1 by "S.R.Anand Kumar" <anands@m...> on Fri, 28 Feb 2003 10:11:56 +0530
If you're passing a Page, you shouldn't be using the Control type, but the 
Page type instead. In fact, you should be passing it as an object of 
whatever type you created, inheriting from System.Web.UI.Page. Remember 
that pages are objects too, so you can always access its properties simply 
by declaring your variable to be of that type.

public class MyPage : System.Web.UI.Page
{
     private string s;

     public string MyString
     {
         get { return s; }
     }
}

public class MyClass
{
     public void PassPage (MyPage page)
     {
         string s = page.MyString;
     }
}

At 10:11 AM 2/28/2003 +0530, S.R.Anand Kumar wrote:
>I have a Page in which i have declared few public properties.
> From this page i am calling a method in another class X by passing this
>page as a Control reference.
>eg. PassPage(this)
>
>Class X {
>...
>     PassPage (Control page){
>         access the properties of the passed page... and do something
>     }
>...
>}

::::::::::::::::::::::::::::::::::
Howard Cheng
http://www.howcheng.com/
howcheng at ix dot netcom dot com
AIM: bennyphoebe
ICQ: 47319315


  Return to Index