摘要:[VB.NET] ASP.NET 尋找 MasterPage 下的控制項
今天剛好要找一個屬性的定義方法找了幾篇文張寫了一下的程式
主要功能是要讓滑鼠移到label上就自動打開 AspxPopupControl
程式碼
Dim cp As ContentPlaceHolder '宣告一個定義內容的區域
cp = DirectCast(Master.FindControl("ContentPlaceHolder1"), ContentPlaceHolder) '轉型
For Each con As Object In cp.Controls '尋找控制項
If TypeOf con Is DevExpress.Web.ASPxEditors.ASPxLabel Then '判斷此控制項是否為AspxLabel型態
Dim b As DevExpress.Web.ASPxEditors.ASPxLabel = TryCast(con, DevExpress.Web.ASPxEditors.ASPxLabel) '轉型
If b.ID = "Label_SRNUMBER" Then '判斷此Label的id是否是Label_SRNUMBER
b.Attributes.Add("onmouseover", "PopupDetail.Show(this);") '增加一個屬性
b.Attributes.Add("onmouseout", "PopupDetail.Hide(this);") '增加一個屬性
End If
End If
Next