The. aspx page only pulls one TextBox Control:
Copy codeThe Code is as follows:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default. aspx. cs" Inherits = "_ Default" %>
<! 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 runat = "server">
<Title> </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Asp: TextBox ID = "TextBox1" runat = "server"> </asp: TextBox>
</Form>
</Body>
</Html>
In the. aspx. cs page, you are preferred to register the OnBlur event for the TextBox in the Page_Init event:
Copy codeThe Code is as follows:
Protected void Page_Init (object sender, EventArgs e)
{
This. TextBox1.Attributes. Add ("onblur", Page. ClientScript. GetPostBackEventReference (this. TextBox1, "OnBlur "));
}
Write an onBlue event to replace the Click Event of the LinkButton:
Copy codeThe Code is as follows:
Private void OnBlurHandle (string ctrl, string args)
{
If (ctrl = this. TextBox1.UniqueID & args = "OnBlur ")
{
// Write and submit it to the database
}
}
Then, in the Page_Load event of the webpage, determine whether IsPostBack is used.
Copy codeThe Code is as follows:
Protected void Page_Load (object sender, EventArgs e)
{
If (IsPostBack)
{
Var ctrl = Request. Params [Page. postEventSourceID];
Var args = Request. Params [Page. postEventArgumentID];
OnBlurHandle (ctrl, args );
}
}