以前一直沒有注意這個問題,就是自己寫的ASP.NET服務器控件,即Web Custom Control。將控件拖動到頁面上會有如下的標記:
<cc1:ExListBox ID='ExListBox1' Runat='server'> </cc1:ExListBox>
在頁面的頁頭也有這樣的語法標識
<%@ Register tagprefix='cc1' Namespace='namespace' Assembly='assembly' %>
如果將這裏的cc1修改爲理想的TagName,那以後再拖動對應的Namespace下的控件,就均以TagName開始了。
但是,也許在Web Control 的代碼中進行設置,應該就不會這麼麻煩吧,還再來頁面修改。 那就是需要使用TagPrefix屬性(Attribute)。如下所示:
[assembly:TagPrefix('CustomControls', 'custom')]
namespace CustomControls
{
// Simple custom control
public class ExListBox: Control
{
//....
}
CustomControls是指命名空間,custom指希望使用的TagName
參考: MSDN TagPrefix property