Exposing UserControl in a MasterPage

G

Guest

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
 
B

bruce barker

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)
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top