利用公有Event响应usercontrol事件

在masterpage中为自定义控件留出位置,在画面中进行调用。

在usercontrol里公开event事件,然后就可以在画面中直接进行响应了

 

SyokuinListArea.ascx.vb
 
#Region " 公開するイベント定義"
    ' 支給年月区分が変更されたイベント
    Public Delegate Sub ShikyuNengetsuKubunChangedEventHandler(ByVal sender As Object, ByVal e As TaisyoSyokuinEventArgs)
    Public Event ShikyuNengetsuKubunChanged As ShikyuNengetsuKubunChangedEventHandler
 
    Protected Overridable Sub OnShikyuNengetsuKubunChanged(ByVal sender As Object, ByVal e As TaisyoSyokuinEventArgs)
        RaiseEvent ShikyuNengetsuKubunChanged(sender, e)
    End Sub
 
#End Region
 
    Protected Sub DummyShikyuNengetsuKubunChangedButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DummyShikyuNengetsuKubunChangedButton.Click
        Dim tse As New TaisyoSyokuinEventArgs
        tse.ShikyuNengetsu = DummyShikyuNengetsu.Text
        tse.ShikyuKubun = DummyShikyuKubun.Text
        tse.SyokuinBango = DummySyokuinBango.Text
 
        OnShikyuNengetsuKubunChanged(sender, tse)
    End Sub
 
 
Masterpage.master.vb
    <td valign="top" style="height: 1px">
        <!-- 順番ナビエリア 開始-->
        <asp:ContentPlaceHolder ID="SyokuinListArea" runat="server">
        </asp:ContentPlaceHolder>
        <!-- 順番ナビエリア 終了-->
    </td>
 
QYO1250.aspx
<% @ Page Language="VB" MasterPageFile="~/Asp/Master/KojinMaintenanceLayout.master" AutoEventWireup="false" CodeFile="QYO1250.aspx.vb" Inherits="Asp_QYO1250" title=" 給与履歴保守 " %>
<% @ Register Src="../UserControl/SyokuinListArea.ascx" TagName="SyokuinListArea" TagPrefix="UserCtl" %>
 
< asp : Content ID="cntPage1" ContentPlaceHolderID="SyokuinListArea" Runat="Server" EnableViewState="false">
    <!-- 職員一覧エリア 開始-->
    <UserCtl:SyokuinListArea ID="SyokuinListArea" runat="server" />
    <!-- 職員一覧エリア 終了-->
</ asp : Content >
 
QYO1250.vb
    Public Sub UserControl_SyokuinTaisyoArea_ChangedToGenBango(ByVal sender As Object, ByVal tse As TaisyoSyokuinEventArgs) Handles SyokuinListArea.ShikyuNengetsuKubunChanged
 
        MsgBox(tse.ShikyuNengetsu + " " + tse.ShikyuKubun + " " + tse.SyokuinBango)
    End Sub

 

你可能感兴趣的:(利用公有Event响应usercontrol事件)