tags:

views:

1004

answers:

2

Hi all,

I have a number of custom controls that I am trying to enable designer support for. The signature looks something like the following:

[ToolboxData("<{0}:MyDropDownList runat=\"server\" CustomProp="123"></{0}:MyDropDownList>")]
public class MyDropDownList: DropDownList
{
   ... code here
}

This works fine, but when I drag a control onto the page from the toolbox, the TagPrefix that gets added is "cc1":

<%@ Register Assembly="DBMClientPortal.Controls" Namespace="DBMClientPortal.Controls"
    TagPrefix="cc1" %>

Obviously it is somewhat irrelevant what that TagPrefix is... it works as it stands, but I figured I must be able to change it somehow and curiosity got the better of me...

Anyone know how to define what the TagPrefix will be set to when dragging a custom control onto a page in visual studio?

Thanks, Max

+2  A: 

It looks something like this:

[assembly:TagPrefix("MyControls","RequiredTextBox")]

and here's some more info about it.

DOK
A: 

FYI, the TagPrefix attribute is only a suggestion to Visual Studio and other designer tools. If the user already has your namespace registered to a different tag prefix then it is free to use that tag prefix. Also, if your suggested tag prefix is already in use and points to a different namespace, the Visual Studio will use an auto-generated tag prefix instead.

However, the odds of either one of those happening is fairly small if you choose a tag prefix that is based on your product's or company's name.

Eilon