TextBox.OnTextChanged(EventArgs) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
TextChanged 이벤트를 발생시킵니다. 이렇게 하면 이벤트를 직접 처리할 수 있습니다.
protected:
virtual void OnTextChanged(EventArgs ^ e);
protected virtual void OnTextChanged(EventArgs e);
abstract member OnTextChanged : EventArgs -> unit
override this.OnTextChanged : EventArgs -> unit
Protected Overridable Sub OnTextChanged (e As EventArgs)
매개 변수
예제
다음 코드 예제에서는 항상 사용자 지정 OnTextChanged 서버 컨트롤이 수정된 것으로 표시되도록 메서드를 재정 TextBox 의하는 방법을 보여 줍니다.
Important
이 예제에는 잠재적인 보안 위협인 사용자 입력을 허용하는 텍스트 상자가 있습니다. 기본적으로 ASP.NET 웹 페이지는 사용자 입력에 스크립트 또는 HTML 요소가 포함되지 않는지 확인합니다. 자세한 내용은 스크립트 악용 개요를 참조하세요.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Custom TextBox - OnTextChanged - C# Example</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom TextBox - OnTextChanged - C# Example</h3>
<aspSample:CustomTextBoxOnTextChanged
id="TextBox1"
autopostback=true
runat="server">Hello World!
</aspSample:CustomTextBoxOnTextChanged>
</form>
</body>
</html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Custom TextBox - OnTextChanged - VB.NET Example</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom TextBox - OnTextChanged - VB.NET Example</h3>
<aspSample:CustomTextBoxOnTextChanged id="TextBox1" autopostback=true
runat="server">Hello World!</aspSample:CustomTextBoxOnTextChanged>
</form>
</body>
</html>
using System.Web;
using System.Security.Permissions;
namespace Samples.AspNet.CS.Controls
{
[AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class CustomTextBoxOnTextChanged : System.Web.UI.WebControls.TextBox
{
private bool isDirty = false;
protected override void OnTextChanged(System.EventArgs e)
{
// Call the base OnTextChanged method.
base.OnTextChanged(e);
// Change the dirty flag to True.
isDirty = true;
}
}
}
Imports System.Web
Imports System.Security.Permissions
Namespace Samples.AspNet.VB.Controls
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomTextBoxOnTextChanged
Inherits System.Web.UI.WebControls.TextBox
Private isDirty As Boolean = False
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
' Call the base OnTextChanged method.
MyBase.OnTextChanged(e)
' Change the dirty flag to True.
isDirty = True
End Sub
End Class
End Namespace
설명
이 TextChanged 이벤트는 텍스트 상자의 내용이 서버에 대한 게시물 간에 변경될 때 발생합니다.
메모
TextBox 이 이벤트가 제대로 작동하려면 컨트롤이 서버에 대한 게시물 간에 일부 값을 유지해야 합니다. 이 컨트롤에 대해 뷰 상태가 사용하도록 설정되어 있는지 확인합니다.
이벤트를 발생시키는 경우 대리자를 통해 이벤트 처리기가 호출됩니다. 자세한 내용은 이벤트 처리 및 발생을 참조하세요.
또한 이 OnTextChanged 메서드를 사용하면 파생 클래스가 대리자를 연결하지 않고도 이벤트를 처리할 수 있습니다. 파생 클래스에서 이벤트를 처리하기 위한 기본 설정 기술입니다.
상속자 참고
파생 클래스에서 재정의하는 OnTextChanged(EventArgs) 경우 등록된 대리자가 이벤트를 받도록 기본 클래스의 OnTextChanged(EventArgs) 메서드를 호출해야 합니다.