Abundant Technologies - IT Consulting Experts

 Source Code Library

 Code Details

 
'ASCX file '********************************************** Public Class SideMenu Inherits System.Web.UI.UserControl Private Const BUTTON_NAME As String = "btnSideMenu_" Private m_Buttons As String = "" Private m_URL As String = "" Private m_Version As String = "x.x" Private m_ImagePath As String = "" Private m_ButtomImagePath As String = "" Private m_ButtonToolTip As String = "" ' Delegate declaration Public Delegate Sub MenuClickHandler(ByVal sender As Object, ByVal e As EventArgs) ' Event declaration Public Event MenuClick As MenuClickHandler Public Property ImagePath() As String Get ImagePath = m_ImagePath End Get Set(ByVal Value As String) m_ImagePath = Value End Set End Property Public Property ButtonImages() As String Get ButtonImages = m_Buttons End Get Set(ByVal Value As String) m_Buttons = Value End Set End Property Public Property ButtonURLs() As String Get ButtonURLs = m_URL End Get Set(ByVal Value As String) m_URL = Value End Set End Property Public Property AppVersion() As String Get AppVersion = m_Version End Get Set(ByVal Value As String) m_Version = Value End Set End Property Public Property ButtomImagePath() As String Get ButtomImagePath = m_ButtomImagePath End Get Set(ByVal Value As String) m_ButtomImagePath = Value End Set End Property Public Property ButtonToolTips() As String Get ButtonToolTips = m_ButtonToolTip End Get Set(ByVal Value As String) m_ButtonToolTip = Value End Set End Property #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Protected WithEvents btnSideMenu As System.Web.UI.WebControls.ImageButton Protected imgSideMenu As System.Web.UI.WebControls.Image Protected WithEvents pnlSideMenu As System.Web.UI.WebControls.Panel 'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceholderDeclaration As System.Object Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Dim iCount As Int16 Dim aButtons() As String = Split(m_Buttons, ",") Dim aURLs() As String = Split(m_URL, ",") Dim aTips() As String = Split(m_ButtonToolTip, ",") Dim table As New System.Web.UI.WebControls.Table Dim tr As System.Web.UI.WebControls.TableRow Dim td As System.Web.UI.WebControls.TableCell Dim imgTop As System.Web.UI.WebControls.Image Dim imgBottom As System.Web.UI.WebControls.Image Dim lbVersion As System.Web.UI.WebControls.Label table.CellPadding = 0 table.CellSpacing = 0 table.GridLines = GridLines.None table.Width = Unit.Percentage(100) table.Height = Unit.Percentage(100) tr = New TableRow td = New TableCell td.HorizontalAlign = HorizontalAlign.Left imgTop = New System.Web.UI.WebControls.Image imgTop.Height = Unit.Pixel(54) imgTop.Width = Unit.Pixel(132) imgTop.ImageUrl = m_ImagePath & "navtop.gif" td.Controls.Add(imgTop) tr.Controls.Add(td) table.Controls.AddAt(0, tr) For iCount = 0 To aButtons.Length - 1 If aButtons(iCount).ToLower.IndexOf("_disable.gif") > 0 Or aButtons(iCount).ToLower.IndexOf("_sel.gif") > 0 Then imgSideMenu = New System.Web.UI.WebControls.Image imgSideMenu.ImageUrl = m_ImagePath & aButtons(iCount) tr = New TableRow td = New TableCell td.HorizontalAlign = HorizontalAlign.Left td.Controls.Add(imgSideMenu) Else btnSideMenu = New ImageButton btnSideMenu.ID = BUTTON_NAME & iCount.ToString() btnSideMenu.ImageUrl = m_ImagePath & aButtons(iCount) btnSideMenu.AlternateText = aTips(iCount) btnSideMenu.Attributes.Add("TargetURL", aURLs(iCount)) AddHandler btnSideMenu.Click, AddressOf btnSideMenu_Click tr = New TableRow td = New TableCell td.HorizontalAlign = HorizontalAlign.Left td.Controls.Add(btnSideMenu) End If tr.Controls.Add(td) table.Controls.AddAt(iCount + 1, tr) Next tr = New TableRow td = New TableCell td.VerticalAlign = VerticalAlign.Bottom td.HorizontalAlign = HorizontalAlign.Center td.Style.Add("background-image", "url(" & m_ButtomImagePath & "navbottom.gif)") lbVersion = New Label lbVersion.Font.Size = FontUnit.XXSmall lbVersion.Text = "Version: " & m_Version td.Controls.Add(lbVersion) tr.Height = Unit.Percentage(100) tr.Controls.Add(td) table.Controls.AddAt(iCount + 1, tr) pnlSideMenu.Controls.Add(table) End Sub Private Sub btnSideMenu_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) RaiseEvent MenuClick(sender, e) End Sub End Class '********************************************** 'Parent ASPX HTML '********************************************** '********************************************** 'Parent ASPX Code Behind '********************************************** Protected WithEvents SideMenu1 As SideMenu Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here SideMenu1.AppVersion = "x.x.x" SideMenu1.ImagePath = "images/" SideMenu1.ButtomImagePath = "../images/" SideMenu1.ButtonToolTips = "Button 1, Button 2, Button 3" SideMenu1.ButtonImages = "image1.gif,image2.gif,image3.gif" SideMenu1.ButtonURLs = "page1.aspx,page2.aspx,page3.aspx" End Sub Protected Sub SideMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 'Handle event here End Sub '**********************************************

Mail To: info@3pc.com