Hi,
JJ wrote:
If I create a class library that has a document class that I created
and I call the class in an aspx page it is now an object of the
document class. Now when I call a method that is part of the object,
just as you guys have above I wanted to know if its possible to call
Page.RegisterClientScriptBlock and it would know to register it for
that given page. I see I would have to pass in the a reference to the
page in my method correct? Am I using the right terminology here in my
explanation?
Thanks,
JJ
The thing is: You need a reference to the Page containing the object you
created. There are many ways to get a reference to the Page your control
is into (see Karl's and my proposals). Your design must plan a way to
get the Page's reference, one way or the other.
Let's say you're in the Page_Load event handler, and you do:
MyObject myObject = new MyObject();
With this code, your "MyObject" instance doesn't have any reference to
the Page class. This is a unidirectional composition in UML. If you want
to pass a reference from the Page to the MyObject, you need something like:
MyObject myObject = new MyObject( this );
This is then bidirectional, means that you can reach the MyObject from
the Page, and you can also reach the Page from the MyObject.
Is that clearer?
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering:
http://www.galasoft-LB.ch
Private/Malaysia:
http://mypage.bluewin.ch/lbugnion
Support children in Calcutta:
http://www.calcutta-espoir.ch