ClientScriptManager.GetPostBackEventReference 메서드

정의

서버에 다시 게시 작업을 발생시키는 클라이언트 이벤트에 사용할 수 있는 문자열을 반환합니다.

오버로드

GetPostBackEventReference(Control, String, Boolean)

서버에 다시 게시 작업을 발생시키는 클라이언트 이벤트에 사용할 문자열을 반환합니다. 참조 문자열은 다시 게시 작업과 추가 이벤트 정보의 문자열 인수를 처리하는 지정된 컨트롤에 의해 정의됩니다. 유효성 검사에 대한 이벤트 참조도 선택적으로 등록합니다.

GetPostBackEventReference(PostBackOptions, Boolean)

서버에 다시 게시 작업을 발생시키는 클라이언트 이벤트에 사용할 수 있는 문자열을 반환합니다. 참조 문자열은 지정된 PostBackOptions 개체에 의해 정의됩니다. 유효성 검사에 대한 이벤트 참조도 선택적으로 등록합니다.

GetPostBackEventReference(PostBackOptions)

서버에 다시 게시 작업을 발생시키는 클라이언트 이벤트에 사용할 수 있는 문자열을 반환합니다. 참조 문자열은 지정한 PostBackOptions 인스턴스에 의해 정의됩니다.

GetPostBackEventReference(Control, String)

서버에 다시 게시 작업을 발생시키는 클라이언트 이벤트에 사용할 수 있는 문자열을 반환합니다. 참조 문자열은 다시 게시 작업과 추가 이벤트 정보의 문자열 인수를 처리하는 지정된 컨트롤에 의해 정의됩니다.

GetPostBackEventReference(Control, String, Boolean)

서버에 다시 게시 작업을 발생시키는 클라이언트 이벤트에 사용할 문자열을 반환합니다. 참조 문자열은 다시 게시 작업과 추가 이벤트 정보의 문자열 인수를 처리하는 지정된 컨트롤에 의해 정의됩니다. 유효성 검사에 대한 이벤트 참조도 선택적으로 등록합니다.

public:
 System::String ^ GetPostBackEventReference(System::Web::UI::Control ^ control, System::String ^ argument, bool registerForEventValidation);
public string GetPostBackEventReference (System.Web.UI.Control control, string argument, bool registerForEventValidation);
member this.GetPostBackEventReference : System.Web.UI.Control * string * bool -> string
Public Function GetPostBackEventReference (control As Control, argument As String, registerForEventValidation As Boolean) As String

매개 변수

control
Control

서버에서 다시 게시 작업을 처리하는 서버 Control입니다.

argument
String

control에 전달할 선택적 인수의 문자열입니다.

registerForEventValidation
Boolean

유효성 검사에 대한 이벤트 참조를 등록하려면 true이고, 그렇지 않으면 false입니다.

반환

String

클라이언트의 스크립트로 처리될 때 다시 게시 작업을 시작하는 문자열입니다.

예외

지정된 Controlnull입니다.

설명

에 대한 인터페이스를 Page구현 IPostBackEventHandler 하려면 지시문을 사용합니다@ Implements.

GetPostBackEventReference 메서드를 사용 하 여 사용할 수 있습니다를 Button 시기를 제어 합니다 UseSubmitBehavior 속성이 false합니다. 이 시나리오에서는 합니다 GetPostBackEventReference 메서드가 반환 되는 클라이언트 포스트백에 대 한 이벤트를 Button 제어 합니다.

하는 경우 registerForEventValidation 가 true 이면 합니다 GetPostBackEventReference(PostBackOptions, Boolean) 메서드 호출을 RegisterForEventValidation(String, String) 이벤트를 생성 하는 클라이언트 컨트롤을 나타내는 고유 컨트롤 ID를 사용 하 여 유효성 검사에 대 한 이벤트 참조를 등록 하는 방법.

추가 정보

적용 대상

GetPostBackEventReference(PostBackOptions, Boolean)

서버에 다시 게시 작업을 발생시키는 클라이언트 이벤트에 사용할 수 있는 문자열을 반환합니다. 참조 문자열은 지정된 PostBackOptions 개체에 의해 정의됩니다. 유효성 검사에 대한 이벤트 참조도 선택적으로 등록합니다.

public:
 System::String ^ GetPostBackEventReference(System::Web::UI::PostBackOptions ^ options, bool registerForEventValidation);
public string GetPostBackEventReference (System.Web.UI.PostBackOptions options, bool registerForEventValidation);
member this.GetPostBackEventReference : System.Web.UI.PostBackOptions * bool -> string
Public Function GetPostBackEventReference (options As PostBackOptions, registerForEventValidation As Boolean) As String

매개 변수

options
PostBackOptions

다시 게시를 정의하는 PostBackOptions입니다.

registerForEventValidation
Boolean

유효성 검사에 대한 이벤트 참조를 등록하려면 true이고, 그렇지 않으면 false입니다.

반환

String

클라이언트의 스크립트로 처리될 때 클라이언트 다시 게시 작업을 시작하는 문자열입니다.

예외

설명

개체에 IPostBackEventHandler 대한 인터페이스를 Page 구현하려면 지시문을 사용합니다 @ Implements .

GetPostBackEventReference 메서드를 사용 하 여 사용할 수 있습니다를 Button 시기를 제어 합니다 UseSubmitBehavior 속성이 false합니다. 이 시나리오에서는 합니다 GetPostBackEventReference 메서드가 반환 되는 클라이언트 포스트백에 대 한 이벤트를 Button 제어 합니다.

경우 registerForEventValidation 됩니다 trueGetPostBackEventReference(PostBackOptions, Boolean) 메서드 호출을 RegisterForEventValidation(String, String) 이벤트를 생성 하는 클라이언트 컨트롤을 나타내는 고유 컨트롤 ID를 사용 하 여 유효성 검사에 대 한 이벤트 참조를 등록 하는 방법.

추가 정보

적용 대상

GetPostBackEventReference(PostBackOptions)

서버에 다시 게시 작업을 발생시키는 클라이언트 이벤트에 사용할 수 있는 문자열을 반환합니다. 참조 문자열은 지정한 PostBackOptions 인스턴스에 의해 정의됩니다.

public:
 System::String ^ GetPostBackEventReference(System::Web::UI::PostBackOptions ^ options);
public string GetPostBackEventReference (System.Web.UI.PostBackOptions options);
member this.GetPostBackEventReference : System.Web.UI.PostBackOptions -> string
Public Function GetPostBackEventReference (options As PostBackOptions) As String

매개 변수

options
PostBackOptions

다시 게시를 정의하는 PostBackOptions입니다.

반환

String

클라이언트의 스크립트로 처리될 때 클라이언트 다시 게시 작업을 시작하는 문자열입니다.

예외

PostBackOptions 매개 변수가 null입니다.

설명

에 대한 인터페이스를 Page구현 IPostBackEventHandler 하려면 지시문을 사용합니다@ Implements.

GetPostBackEventReference 메서드를 사용 하 여 사용할 수 있습니다를 Button 시기를 제어 합니다 UseSubmitBehavior 속성이 false합니다. 이 시나리오에서는 합니다 GetPostBackEventReference 메서드가 반환 되는 클라이언트 포스트백에 대 한 이벤트를 Button 제어 합니다.

추가 정보

적용 대상

GetPostBackEventReference(Control, String)

서버에 다시 게시 작업을 발생시키는 클라이언트 이벤트에 사용할 수 있는 문자열을 반환합니다. 참조 문자열은 다시 게시 작업과 추가 이벤트 정보의 문자열 인수를 처리하는 지정된 컨트롤에 의해 정의됩니다.

public:
 System::String ^ GetPostBackEventReference(System::Web::UI::Control ^ control, System::String ^ argument);
public string GetPostBackEventReference (System.Web.UI.Control control, string argument);
member this.GetPostBackEventReference : System.Web.UI.Control * string -> string
Public Function GetPostBackEventReference (control As Control, argument As String) As String

매개 변수

control
Control

서버에서 다시 게시 작업을 처리하는 서버 Control입니다.

argument
String

다시 게시 작업을 처리하는 컨트롤에 전달할 선택적 인수의 문자열입니다.

반환

String

클라이언트의 스크립트로 처리될 때 다시 게시 작업을 시작하는 문자열입니다.

예외

지정된 Controlnull입니다.

예제

다음 코드 예제에서는 GetPostBackEventReference 메서드. 사용자 지정 컨트롤 MyControl를 구현 하는 IPostBackEventHandler 인터페이스입니다. 페이지의 단추를 클릭 하면는 RaisePostBackEvent 사용자 지정 컨트롤의 메서드가 호출 됩니다.

<%@ Page Language="C#"  %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  public class MyControl : Label, IPostBackEventHandler
  {

    // Use the constructor to defined default label text.
    public MyControl()
    {
      base.Text = "No postback raised.";
    }
    
    // Implement the RaisePostBackEvent method from the
    // IPostBackEventHandler interface. 
    public void RaisePostBackEvent(string eventArgument)
    {
      base.Text = "Postback handled by " + this.ID.ToString() + ". <br/>" +
                  "Postback caused by " + eventArgument.ToString() + ".";
      
    }
  }

  protected void Page_Load(object sender, EventArgs e)
  {
    // Get a ClientScriptManager reference from the Page class.
    ClientScriptManager cs = Page.ClientScript;

    // Create an instance of the custom label control and 
    // add it to the page.
    MyControl mycontrol = new MyControl();
    mycontrol.ID = "mycontrol1";
    PlaceHolder1.Controls.Add(mycontrol);
    PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
    
    // Create a button element with its onClick attribute defined
    // to create a postback event reference to the custom label control.
    HtmlInputButton b = new HtmlInputButton();
    b.ID = "mybutton1";
    b.Value = "Click";
    b.Attributes.Add("onclick", cs.GetPostBackEventReference(mycontrol, b.ID.ToString()));
    PlaceHolder1.Controls.Add(b);
    PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
    
    // Create a link element with its href attribute defined
    // to create a postback event reference to the custom label control.
    HtmlAnchor a = new HtmlAnchor();
    a.ID = "myanchor1";
    a.InnerText = "link";
    a.HRef = cs.GetPostBackClientHyperlink(mycontrol, a.ID.ToString());
    PlaceHolder1.Controls.Add(a);
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ClientScriptManager Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:PlaceHolder id="PlaceHolder1" 
                       runat="server">
      </asp:PlaceHolder>
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  
  Public Class MyControl
    Inherits Label
    Implements IPostBackEventHandler
     
    Public Sub New()
      
      MyBase.Text = "No postback raised."
    
    End Sub
    
    Public Sub RaisePostBackEvent(ByVal eventArgument As String) Implements System.Web.UI.IPostBackEventHandler.RaisePostBackEvent
      
      MyBase.Text = "Postback handled by " & Me.ID.ToString() & ". <br/>" & _
                "Postback caused by " + eventArgument.ToString() & "."

    End Sub
    
  End Class
   

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    ' Get a ClientScriptManager reference from the Page class.
    Dim cs As ClientScriptManager = Page.ClientScript

    ' Create an instance of the custom label control and 
    ' add it to the page.
    Dim mycontrol As New MyControl()
    MyControl.ID = "mycontrol1"
    PlaceHolder1.Controls.Add(MyControl)
    PlaceHolder1.Controls.Add(New LiteralControl("<br/>"))
    
    ' Create a button element with its onClick attribute defined
    ' to create a postback event reference to the custom label control.
    Dim b As New HtmlInputButton()
    b.ID = "mybutton1"
    b.Value = "Click"
    b.Attributes.Add("onclick", cs.GetPostBackEventReference(MyControl, b.ID.ToString()))
    PlaceHolder1.Controls.Add(b)
    PlaceHolder1.Controls.Add(New LiteralControl("<br/>"))
    
    ' Create a link element with its href attribute defined
    ' to create a postback event reference to the custom label control.
    Dim a As New HtmlAnchor()
    a.ID = "myanchor1"
    a.InnerText = "link"
    a.HRef = cs.GetPostBackClientHyperlink(MyControl, a.ID.ToString())
    PlaceHolder1.Controls.Add(a)
    
  End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>ClientScriptManager Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:PlaceHolder id="PlaceHolder1" 
                       runat="server">
      </asp:PlaceHolder>
    </div>
    </form>
</body>
</html>

다음 코드 예제에서는 사용자 지정 컨트롤을 대신 이전과 동일한 기능이 합니다 Page 구현 클래스는 IPostBackEventHandler 인터페이스입니다.

<%@ Page Language="C#"  %>
<%@ Implements Interface="System.Web.UI.IPostBackEventHandler" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  
  public void RaisePostBackEvent(string eventArgument)
  {
    Label1.Text = "Postback handled by " + this.ID.ToString() + ". <br/>" +
                  "Postback caused by " + eventArgument.ToString() + "."; ;
  }
  
  protected void Page_Load(object sender, EventArgs e)
  {
    // Get a ClientScriptManager reference from the Page class.
    ClientScriptManager cs = Page.ClientScript;
    
    // Create a button element with its onClick attribute defined
    // to create a postback event reference to the custom label control.
    HtmlInputButton b = new HtmlInputButton();
    b.ID = "mybutton1";
    b.Value = "Click";
    b.Attributes.Add("onclick", cs.GetPostBackEventReference(this, b.ID.ToString()));
    PlaceHolder1.Controls.Add(b);
    PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
    
    // Create a link element with its href attribute defined
    // to create a postback event reference to the custom label control.
    HtmlAnchor a = new HtmlAnchor();
    a.ID = "myanchor1";
    a.InnerText = "link";
    a.HRef = cs.GetPostBackClientHyperlink(this, a.ID.ToString());
    PlaceHolder1.Controls.Add(a);
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ClientScriptManager Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:Label id="Label1"
                 runat="server" />
      <br />
      <asp:PlaceHolder id="PlaceHolder1" 
                       runat="server">
      </asp:PlaceHolder>
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Implements Interface="System.Web.UI.IPostBackEventHandler" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
 
  Public Sub RaisePostBackEvent(ByVal eventArgument As String) _
    Implements IPostBackEventHandler.RaisePostBackEvent
    
    Label1.Text = "Postback handled by " & Me.ID.ToString() & ". <br/>" & _
           "Postback caused by " + eventArgument.ToString() & "."
  
  End Sub
  

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    ' Get a ClientScriptManager reference from the Page class.
    Dim cs As ClientScriptManager = Page.ClientScript
    
    ' Create a button element with its onClick attribute defined
    ' to create a postback event reference to the custom label control.
    Dim b As New HtmlInputButton()
    b.ID = "mybutton1"
    b.Value = "Click"
    b.Attributes.Add("onclick", cs.GetPostBackEventReference(Me, b.ID.ToString()))
    PlaceHolder1.Controls.Add(b)
    PlaceHolder1.Controls.Add(New LiteralControl("<br/>"))
    
    ' Create a link element with its href attribute defined
    ' to create a postback event reference to the custom label control.
    Dim a As New HtmlAnchor()
    a.ID = "myanchor1"
    a.InnerText = "link"
    a.HRef = cs.GetPostBackClientHyperlink(Me, a.ID.ToString())
    PlaceHolder1.Controls.Add(a)
    
  End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ClientScriptManager Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:Label id="Label1"
                 runat="server" />
      <br />
      <asp:PlaceHolder id="PlaceHolder1" 
                       runat="server">
      </asp:PlaceHolder>
    </div>
    </form>
</body>
</html>

설명

에 대한 인터페이스를 Page구현 IPostBackEventHandler 하려면 지시문을 사용합니다@ Implements.

GetPostBackEventReference 메서드를 사용 하 여 사용할 수 있습니다를 Button 시기를 제어 합니다 UseSubmitBehavior 속성이 false합니다. 이 시나리오에서는 합니다 GetPostBackEventReference 메서드가 반환 되는 클라이언트 포스트백에 대 한 이벤트를 Button 제어 합니다.

추가 정보

적용 대상