나는 그것을 이런 식으로 일한다고 생각 : 그것의 텍스트 상태로 발사 있기 때문에
TextBox 컨트롤 대신 IPostBackEventHandler의의 IPostBackDataHandler를 구현합니다. 따라서 어떤 변경 사항이 결정된 postedValue에서 발생하면
if (presentValue == null || !presentValue.Equals(postedValue)) {
Text = postedValue;
return true;
}
부분을 true로 반환하고 마지막으로 TextChanged가 실행되도록 유지합니다. Pff는 혼란 스럽지만 쉽게 보입니다. 이 컨트롤 국가는의 IPostBackDataHandler이 텍스트 상자에 의해 구현된다 그래서 이유 경우
using System;
using System.Web;
using System.Web.UI;
using System.Collections;
using System.Collections.Specialized;
namespace CustomWebFormsControls {
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
public class MyTextBox: Control, IPostBackDataHandler {
public String Text {
get {
return (String) ViewState["Text"];
}
set {
ViewState["Text"] = value;
}
}
public event EventHandler TextChanged;
public virtual bool LoadPostData(string postDataKey,
NameValueCollection postCollection) {
String presentValue = Text;
String postedValue = postCollection[postDataKey];
if (presentValue == null || !presentValue.Equals(postedValue)) {
Text = postedValue;
return true;
}
return false;
}
public virtual void RaisePostDataChangedEvent() {
OnTextChanged(EventArgs.Empty);
}
protected virtual void OnTextChanged(EventArgs e) {
if (TextChanged != null)
TextChanged(this,e);
}
protected override void Render(HtmlTextWriter output) {
output.Write("<INPUT type= text name = "+this.UniqueID
+ " value = " + this.Text + " >");
}
}
}
그것은 추적 및 제어의 필수 정보를 유지 ControlState 수 있지만 수 있을까요? – Tarik