Textbox lost focus can also trigger server events

zhaozj2021-02-16  82

In the web application! We tend to use a lot of textbox to handle the entry.

Before the page is submitted, when TextBox is lost, it is possible to handle the information we entered.

such as:

1. Check the input information

2, according to the input information, different processing of the information that is about to be entered later

3, need to return to the server processing

and many more...

Based on these requirements! Give Textbox with onblur's server events! Figure:

The server will automatically generate root onclick events.

THIS.MYTEXTBOX.ONBLUR = New System.EventHandler (this.mytextbox_onblur);

The main place in this control is to inherit the TextBox, and the iPostBackeventhandler interface! Open ONBLUR events!

The complete code is as follows:

Using system;

Namespace region.controls {

Public class postbacktextbox: system.Web.ui.webcontrols.textbox, system.web.ui.ipostbackeventhandler

{Protected override void Render (System.Web.UI.HtmlTextWriter writer) {Attributes [ "onblur"] = Page.GetPostBackEventReference (this); base.Render (writer);} public event EventHandler OnBlur; public virtual void RaisePostBackEvent (string eventArgument ) {If (onblur! = Null) {onbrur (this, null);}}

}

转载请注明原文地址:https://www.9cbs.com/read-13250.html

New Post(0)