Whitecat
Whitecat

Reputation: 4020

How do you make a control reusable in different projects?

Is there a way to not put the project name in the Inherits attribute?

I am working with vb and I have multiple projects, that have multiple web pages. In each of these projects I create controls that are reused in the web pages.

Each control I have is declared like this:

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="MenuBarControl.ascx.vb" Inherits="**projectName**.MenuBarControl" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>

When I want to copy the control into another project I have to change the **projectName**. Having to change the project name for each project makes the code not reusable. Changes made to specific projects each time is not reusable.

I want to be able to omit the project name in the Inherits attribute. When I do that now I get an error

Parser Error

Parser Error Message: Could not load type 'MenuBarControl'.

Upvotes: 3

Views: 746

Answers (2)

BlackJack
BlackJack

Reputation: 2876

http://blogs.msdn.com/b/davidebb/archive/2005/10/30/487160.aspx

Basically, you create a DLL and include it in your other projects. Alternatively, you can modify a user control library. More info here: http://webproject.scottgu.com/CSharp/UserControls/UserControls.aspx

Upvotes: 1

Orn Kristjansson
Orn Kristjansson

Reputation: 3485

Just create a new project that includes all the controls, reference that from the web projects.

Upvotes: 2

Related Questions