ClientScriptManager.GetPostBackClientHyperlink 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
서버에 다시 게시하는 클라이언트 이벤트에 사용할 수 있는 참조를 가져옵니다. 이 참조의 시작 부분에는 javascript:가 추가됩니다.
오버로드
| GetPostBackClientHyperlink(Control, String) |
지정된 이벤트 인수를 사용하여 지정된 컨트롤을 서버에 다시 게시하는 클라이언트 이벤트에 사용할 수 있는 참조를 가져옵니다. 이 참조의 시작 부분에는 |
| GetPostBackClientHyperlink(Control, String, Boolean) |
지정된 이벤트 인수와 이벤트 유효성 검사에 대한 다시 게시를 등록할지 여부를 나타내는 부울 값을 사용하여 지정된 컨트롤에 대해 서버에 다시 게시하는 클라이언트 이벤트에 사용할 수 있는 참조를 가져옵니다. 이 참조의 시작 부분에는 |
GetPostBackClientHyperlink(Control, String)
지정된 이벤트 인수를 사용하여 지정된 컨트롤을 서버에 다시 게시하는 클라이언트 이벤트에 사용할 수 있는 참조를 가져옵니다. 이 참조의 시작 부분에는 javascript:라는 문자열이 추가됩니다.
public:
System::String ^ GetPostBackClientHyperlink(System::Web::UI::Control ^ control, System::String ^ argument);
public string GetPostBackClientHyperlink (System.Web.UI.Control control, string argument);
member this.GetPostBackClientHyperlink : System.Web.UI.Control * string -> string
Public Function GetPostBackClientHyperlink (control As Control, argument As String) As String
매개 변수
- control
- Control
다시 게시 작업을 처리하는 서버 컨트롤입니다.
- argument
- String
서버 컨트롤에 전달된 매개 변수입니다.
반환
대상 컨트롤의 ID 및 이벤트 인수를 포함하는 다시 게시 함수에 대한 JavaScript 호출을 나타내는 문자열입니다.
예제
다음 코드 예제에서는 GetPostBackClientHyperlink 메서드. 사용자 지정 컨트롤 MyControl를 구현 하는 IPostBackEventHandler 인터페이스입니다. 페이지의 HTML 앵커 요소를 클릭할 때는 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>
설명
사용 하 여는 GetPostBackEventReference 메서드를 구현 하는 포스트백을 처리 하는 컨트롤에 필요 합니다 IPostBackEventHandler 인터페이스입니다. 에 대한 인터페이스를 Page구현 IPostBackEventHandler 하려면 지시문을 사용합니다@ Implements.
추가 정보
적용 대상
GetPostBackClientHyperlink(Control, String, Boolean)
지정된 이벤트 인수와 이벤트 유효성 검사에 대한 다시 게시를 등록할지 여부를 나타내는 부울 값을 사용하여 지정된 컨트롤에 대해 서버에 다시 게시하는 클라이언트 이벤트에 사용할 수 있는 참조를 가져옵니다. 이 참조의 시작 부분에는 javascript:가 추가됩니다.
public:
System::String ^ GetPostBackClientHyperlink(System::Web::UI::Control ^ control, System::String ^ argument, bool registerForEventValidation);
public string GetPostBackClientHyperlink (System.Web.UI.Control control, string argument, bool registerForEventValidation);
member this.GetPostBackClientHyperlink : System.Web.UI.Control * string * bool -> string
Public Function GetPostBackClientHyperlink (control As Control, argument As String, registerForEventValidation As Boolean) As String
매개 변수
- control
- Control
다시 게시 작업을 처리하는 서버 컨트롤입니다.
- argument
- String
서버 컨트롤에 전달된 매개 변수입니다.
- registerForEventValidation
- Boolean
유효성 검사에 대한 다시 게시 이벤트를 등록하려면 true이고, 그렇지 않으면 false입니다.
반환
대상 컨트롤의 ID 및 이벤트 인수를 포함하는 다시 게시 함수에 대한 JavaScript 호출을 나타내는 문자열입니다.
설명
사용 하 여는 GetPostBackEventReference 메서드를 구현 하는 포스트백을 처리 하는 컨트롤에 필요 합니다 IPostBackEventHandler 인터페이스입니다. 에 대한 인터페이스를 Page구현 IPostBackEventHandler 하려면 지시문을 사용합니다@ Implements.