好吧,我對動態創建的控件的ID感到困惑。ID與UniqueID vs ClientID vs UniqueClientID vs StaticClientID?
Public Class TestClass
Inherits Panel
Implements INamingContainer
Function TestClassInit() Handles Me.Init
Dim pnlMainPanel As New Panel
Me.Controls.Add(pnlMainPanel)
Dim pnlTest1 As New Panel
pnlMainPanel.Controls.Add(pnlTest1)
pnlTest1.ClientIDMode = UI.ClientIDMode.Inherit ' DEFAULT
'pnlTest1.ID = "ctl01"
'pnlTest1.UniqueID = "ctl00$MainPanel$ctl01"
'pnlTest1.ClientID = "MainPanel_ctl01"
'pnlTest1.UniqueClientID = "ctl00_MainPanel_ctl01"
'pnlTest1.StaticClientID = ""
pnlTest1.ClientIDMode = UI.ClientIDMode.Predictable
'pnlTest1.ClientID = "MainPanel_ctl01" (no change)
pnlTest1.ClientIDMode = UI.ClientIDMode.AutoID
'pnlTest1.ClientID = "ctl00_MainPanel_ctl01"
pnlTest1.ClientIDMode = UI.ClientIDMode.Static
'pnlTest1.ClientID = ""
End Function
End Class
爲什麼5個不同的ID?
什麼時候應該使用不同的ID模式?
(我讀的MSDN文檔,但他們像往常一樣,沒有特別的照明。)
如果我不在乎的ID是什麼,只是想增加一個控制&給其ID添加到動態添加的AJAX擴展器,我應該使用哪種模式/ ID組合?
如果你不在乎abt ids爲什麼把他們放在第一位 – Baz1nga
我認爲.NET的MSDN文檔與...相比是非常好的...例如 –