Advanced developer question - accessing a type in dynamically compiled assembly

Topics: Business Logic Layer, Controls
Nov 2, 2011 at 8:14 PM

Hi All,

BE is housed in a Website Project which give it the flexibility of having code dynamically compiled by the server.  One consequesnce of this is that the code from various pages and user controls ends up in different dlls.  This in term makes it difficult for code in one page or user control to be "aware" of other page or user control types.

I have a situation where I need a user control to be able to tell if it's parent is the /post.aspx page and if so it needs to access the post for that page.  The class for the /post.aspx page is named "post" and already has a public property called Post which provides access to the post that it is displaying.

So typially I might have my usercontrol access the post page's Property like this:

if(this.Page is post){

       thePost = ((post)this.Page).Post;


The problem is that since the user control and the post page are in two different dymanically generated assemblies, the user control doesn't have visibility to the post page's type. 

Anyone know how to make it visible to the user control? 



Nov 2, 2011 at 9:44 PM

I think you can always get handler on current .aspx page like this:

var pg = (System.Web.UI.Page)HttpContext.Current.CurrentHandler;

Nov 3, 2011 at 6:56 PM

Thanks Rtur.  I hadn't realized that I coudl get access to the page through HttpContext.Current object.  That's cool thanks.