Button.UseSubmitBehavior 속성

정의

Button 컨트롤에서 클라이언트 브라우저의 전송 메커니즘을 사용하는지 또는 ASP.NET의 포스트백 메커니즘을 사용하는지를 나타내는 값을 가져오거나 설정합니다.

public:
 virtual property bool UseSubmitBehavior { bool get(); void set(bool value); };
[System.Web.UI.Themeable(false)]
public virtual bool UseSubmitBehavior { get; set; }
[<System.Web.UI.Themeable(false)>]
member this.UseSubmitBehavior : bool with get, set
Public Overridable Property UseSubmitBehavior As Boolean

속성 값

Boolean

컨트롤에서 클라이언트 브라우저의 전송 메커니즘을 사용하면 true이고, 그렇지 않으면 false입니다. 기본값은 true입니다.

특성

예제

다음 코드 예제에서는 컨트롤이 서버에 다시 게시할 때 사용하는 제출 메커니즘을 Button 지정하기 위해 속성을 사용하는 UseSubmitBehavior 방법을 보여 줍니다. 속성이 UseSubmitBehavior 설정false되어 단추가 ASP.NET 포스트백 메커니즘을 사용하도록 합니다. 브라우저의 원본 보기 명령을 사용하여 렌더링된 페이지의 소스 코드를 보면 ASP.NET 페이지 프레임워크에서 클라이언트 쪽 스크립트가 추가되어 폼을 서버에 게시하는 것을 볼 수 있습니다.

<%@ 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">
  
  void SubmitBtn_Click(object sender, EventArgs e)
  {
    Message.Text = "Hello World!";    
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="head1" runat="server">
  <title>Button.UseSubmitBehavior Example</title>
</head>
<body>
  <form id="form1" runat="server">

    <h3>Button.UseSubmitBehavior Example</h3> 

    Click the Submit button.
     
    <br /><br /> 

    <!--The value of the UseSubmitBehavior property
    is false. Therefore the button uses the ASP.NET 
    postback mechanism.-->
    <asp:button id="Button1"
      text="Submit"
      onclick="SubmitBtn_Click" 
      usesubmitbehavior="false"
      runat="server"/>       

    <br /><br /> 

    <asp:label id="Message" 
      runat="server"/>

  </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">
    
  Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As EventArgs)
    
    Message.Text = "Hello World!"
    
  End Sub

  </script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  <title>Button.UseSubmitBehavior Example</title>
</head>
<body>
  <form id="form1" runat="server">

    <h3>Button.UseSubmitBehavior Example</h3> 

    Click the Submit button.
      
    <br /><br /> 

    <!--The value of the UseSubmitBehavior property
    is false. Therefore the button uses the ASP.NET 
    postback mechanism.-->
    <asp:button id="Button1"
      text="Submit"
      onclick="SubmitBtn_Click" 
      usesubmitbehavior="false"
      runat="server"/>       

    <br /><br /> 

    <asp:label id="Message" 
      runat="server"/>

  </form>
</body>
</html>

설명

UseSubmitBehavior 이 속성을 사용하여 컨트롤이 Button 클라이언트 브라우저의 제출 메커니즘을 사용하는지 아니면 ASP.NET 포스트백 메커니즘을 사용할지 여부를 지정합니다. 기본적으로 이 속성의 값은 true컨트롤이 Button 브라우저의 제출 메커니즘을 사용하게 합니다. 지정false하는 경우 ASP.NET 페이지 프레임워크는 페이지에 클라이언트 쪽 스크립트를 추가하여 폼을 서버에 게시합니다.

속성이 UseSubmitBehavior 있으면 컨트롤 개발자는 false메서드를 GetPostBackEventReference 사용하여 클라이언트 포스트백 이벤트를 Button반환할 수 있습니다. 메서드에서 반환된 GetPostBackEventReference 문자열은 클라이언트 쪽 함수 호출의 텍스트를 포함하며 클라이언트 쪽 이벤트 처리기에 삽입할 수 있습니다.

이 속성은 테마 또는 스타일시트 테마에 의해 설정될 수 없습니다. 자세한 내용은 ThemeableAttribute 하 고 ASP.NET 테마 및 스킨합니다.

적용 대상

추가 정보