By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,080 Members | 1,817 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,080 IT Pros & Developers. It's quick & easy.

Exposing UserControl in a MasterPage

P: n/a
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
--
Dale Preston
MCAD C#
MCSE, MCDBA
Oct 2 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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)
Dale wrote:
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
Oct 2 '07 #2

P: n/a
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
--
Dale Preston
MCAD C#
MCSE, MCDBA
"bruce barker" wrote:
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)
Dale wrote:
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
Oct 2 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.