Example:
MasterPage.aspx
#Region "Public Delegates"
' Expose delegates for Master Page Events
Public Delegate Sub MasterPageMenuClickHandler(ByVal sender As Object, ByVal e As System.EventArgs)
#End Region
#Region "Public Properties"
Private _currentButton As String
Public Property CurrentButton() As String
Get
Return _currentButton
End Get
Set(ByVal value As String)
_currentButton = value
End Set
End Property
#End Region
#Region "Public Events"
Public Event MenuButton As MasterPageMenuClickHandler
#End Region
#Region "Page Events"
Protected Sub cboLang_Click(ByVal sender As Object, ByVal e As System.EventArgs)
_currentButton = cboLang.SelectedValue
Select Case cboLang.SelectedValue
Case "fr"
Call DLLLallemand.WriteCookies(strGlobalUser, "fr", strAppName)
Case Else
Call DLLLallemand.WriteCookies(strGlobalUser, "en", strAppName)
End Select
OnMenuButton(e)
End Sub
#End Region
#Region "Virtual Methods"
Protected Sub OnMenuButton(ByVal e As EventArgs)
'Invokes the delegates
RaiseEvent MenuButton(Me, e)
End Sub
#End Region
ContentPage.aspx
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
AddHandler Master.MenuButton, New Master_Synergy1.MasterPageMenuClickHandler
(AddressOf Master_MenuButton)
Catch ex As Exception
Finally
End Try
End Sub
Public Sub Master_MenuButton(ByVal sender As Object, ByVal e As System.EventArgs)
strLang = Master.CurrentButton.ToString()
Call MultiLanguage(strLang)
wdgInactiveYeast.Rebind()
End Sub
Reference
http://blogs.claritycon.com/blogs/steve_holstad/archive/2006/03/04/266.aspx
No comments:
Post a Comment