Alexandre Perez
Alexandre Perez

Reputation: 3495

Different reference name for the same custom control

When we write a custom control, like example:

[assembly: TagPrefix("Pro.UI", "pro")]
public class ProTextBox : TextBox 
{
 ...
}

On the HTML coding, we are obliged to reference the control as follows:

<pro:ProTextBox runat="server" ... etc.

My question is:

Is there way to reference the control in the HTML eliminating the prefix "Pro" as follows:

<pro:TextBox runat="server" ... etc.

Best regards.

Upvotes: 0

Views: 46

Answers (1)

Gabe
Gabe

Reputation: 50523

You would have to name the class for the custom control to whatever you want the name to be when going to use it in a page.

Note:

I used the fully qualified namespace when deriving from TextBoxto avoid conflicts

Do something like this:

[assembly: TagPrefix("Pro.UI", "pro")]
public class TextBox : System.Web.UI.WebControls.TextBox
{
 ...
}

Then:

<pro:TextBox runat="server" ... etc.

Upvotes: 1

Related Questions