Home  >  Article  >  Backend Development  >  Implementation code for automatically submitting data when an object loses focus_PHP tutorial

Implementation code for automatically submitting data when an object loses focus_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:15:04845browse

To solve this problem, you need to use onblur. The code below is not the project implementation code, it just simulates the same function.

Copy code The code is as follows:















.aspx.cs:
Copy code The code is as follows:

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI .WebControls;
using Insus.NET;
public partial class _Default : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e)
{
Data_Binding() ;
}
private void Data_Binding()
{
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
//Write here to submit to the database
//The following is Demo use
InsusJsUtility objJs = new InsusJsUtility();
if (string.IsNullOrEmpty(this.TextBox1.Text.Trim()))
{
objJs.JsAlert( "No data to submit. ");
return;
}
objJs.JsAlert("Data has been submitted: " + this.TextBox1.Text);
}
}

The above demo still requires the user to click the LinkButton to submit data. In order for the TextBox's onblur to execute the same event as the LinkButton, we only need to find the "__doPostBack()" of the LinkButton and view the source code:
Implementation code for automatically submitting data when an object loses focus_PHP tutorial.

Attach the yellow highlighted code above to TextBox as onblur event. Write the following code into Data_Binding() of .aspx.cs.
Copy code<.> The code is as follows: this.TextBox1.Attributes.Add("onblur", "__doPostBack('LinkButton1','')");

Finally, we need to change the LinkButton's Text="Submit" to Text="" in order to hide the LinkButton.

http://www.bkjia.com/PHPjc/326142.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326142.htmlTechArticleTo solve this problem, you need to use onblur. The following code is not the project implementation code, it just simulates the same function. Copy the code. The code is as follows: !--Ajax implementation page does not flicker,...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn