IPostBackEventHandler.RaisePostBackEvent(String) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
クラスによって実装された場合は、フォームがサーバーにポストされたときに発生するイベントをサーバー コントロールで処理できるようにします。
public:
void RaisePostBackEvent(System::String ^ eventArgument);
public void RaisePostBackEvent(string eventArgument);
abstract member RaisePostBackEvent : string -> unit
Public Sub RaisePostBackEvent (eventArgument As String)
パラメーター
例
次のコード例では、ポストバックの原因となるカスタム ボタン サーバー コントロールを定義し、 メソッドを使用してポストバック イベントを RaisePostBackEvent キャプチャし、サーバー上でイベントを Click 発生させます。
using System;
using System.Web.UI;
using System.Collections;
using System.Collections.Specialized;
namespace CustomControls {
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
public class MyButton: Control, IPostBackEventHandler {
// Defines the Click event.
public event EventHandler Click;
//Invoke delegates registered with the Click event.
protected virtual void OnClick(EventArgs e) {
if (Click != null) {
Click(this, e);
}
}
// Define the method of IPostBackEventHandler that raises change events.
public void RaisePostBackEvent(string eventArgument){
OnClick(new EventArgs());
}
protected override void Render(HtmlTextWriter output) {
output.Write("<INPUT TYPE = submit name = " + this.UniqueID +
" Value = 'Click Me' />");
}
}
}
Imports System.Web.UI
Imports System.Collections
Imports System.Collections.Specialized
Namespace CustomControls
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> Public Class MyButton
Inherits Control
Implements IPostBackEventHandler
' Define the Click event.
Public Event Click As EventHandler
' Invoke delegates registered with the Click event.
Protected Overridable Sub OnClick(e As EventArgs)
RaiseEvent Click(Me, e)
End Sub
' Define the method of IPostBackEventHandler that raises change events.
Public Sub RaisePostBackEvent(eventArgument As String) _
Implements IPostBackEventHandler.RaisePostBackEvent
OnClick(New EventArgs())
End Sub
Protected Overrides Sub Render(output As HtmlTextWriter)
output.Write("<INPUT TYPE = submit name = " & Me.UniqueID & _
" Value = 'Click Me' />")
End Sub
End Class
End Namespace
注釈
ページは、 インターフェイスを実装する eventArgument コントロールの メソッドに RaisePostBackEvent パラメーターの値を IPostBackEventHandler 渡します。 このコントロールは、ポストバックを発生させる HTML 要素もレンダリングします。 コントロールがポストバック用のクライアント側スクリプトをレンダリングする場合、スクリプトの引数が パラメーターに eventArgument 渡されます。 ポストバックが単純な送信操作によって発生する場合、 eventArgument パラメーターは です null。
このメソッドは、HTML および Web サーバー コントロールによって実装される多くのイベントの機能を提供します。