Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

Exposing UserControl in a MasterPage

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dale - 02 Oct 2007 16:30 GMT
I have an app with a MasterPage.  In the MasterPage is a user control with
several public properties and methods that I want exposed to the content page.

Rather than writing several redirection methods to expose the properties, I
would rather just expose the user control as a property of the MasterPage.

The problem is, when I compile, I get an exception on the content page:

The type 'MessageBlock.MessageBlock' is defined in an assembly that is not
referenced. You must add a reference to assembly
'App_Web_messageblock.ascx.6bb32623.qgtfpxt7, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null'.

What do I need to do to make sure that my project builds into a single
assembly?  It is a web site project and not a web application project.  In
fact, it is a custom web site project as created by the AJAX web site
template.

Thanks,

Dale
Signature

Dale Preston
MCAD C#
MCSE, MCDBA

bruce barker - 02 Oct 2007 16:43 GMT
you have couple options. the best is to define MessageBlock in a class
file in the app_code directory or you can add a reference (@reference
page=mycontrol.ascx) to the user control in any page that uses messageblock.

-- bruce (sqlwork.com)

> I have an app with a MasterPage.  In the MasterPage is a user control with
> several public properties and methods that I want exposed to the content page.
[quoted text clipped - 17 lines]
>
> Dale
Dale - 02 Oct 2007 18:01 GMT
In testing, I tried dropping the user control into the content area of the
content page.  Now the compiler knows that my content page knows about
MessageBlock controls.  Next I deleted the user control from the content
area.  It still compiled.  That left me with  <@ Register Src="whatever" %>.  
The <%@ Reference %> from your suggestion is even better and works.  Thanks.

I do have a question about your first suggestion, though.  I could probably
work this out but a quick tip might save me a lot of time.  

When you say to put the control into a class in app_code, do you mean to
create the item as a web custom control rather than a web user control, and
create all the rendering code myself?  Or do you mean to create a class that
has the user control as a public property or exposes the user control through
encapsulation or delegation?

Thanks,

Dale
Signature

Dale Preston
MCAD C#
MCSE, MCDBA

> you have couple options. the best is to define MessageBlock in a class
> file in the app_code directory or you can add a reference (@reference
[quoted text clipped - 23 lines]
> >
> > Dale

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.