To solve this problem, we need to use onblur to implement it. The following code is not a project implementation code, but simulates the same functionality.
Copy Code code as follows:
<!--AJAX Implementation page does not blink, has been insus.net like to use the-->
<asp:scriptmanager id= "ScriptManager1" runat= "Server" >
</asp:ScriptManager>
<asp:updatepanel id= "UpdatePanel1" runat= "Server" >
<ContentTemplate>
<div>
<!--Place a textbox for the user to enter data-->
<asp:textbox id= "TextBox1" runat= "Server" ></asp:TextBox>
<!--Place a LinkButton, submit data-->
<asp:linkbutton id= "LinkButton1" runat= "Server" text= "Submit" onclick= "LinkButton1_Click" ></asp: Linkbutton>
</div>
</ContentTemplate>
</asp:UpdatePanel>
. Aspx.cs:
Copy Code code 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 and submit to the database
Here 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 demo above still requires the user to click LinkButton to submit the data. For the onblur of the textbox to perform the same events as LinkButton, just find the LinkButton "__doPostBack ()". We can view the source code on the run page:
Add the yellow highlighted code to the textbox as the onblur event. The following code is written in the data_binding () of the. Aspx.cs.
Copy Code code as follows:
This. TEXTBOX1.ATTRIBUTES.ADD ("onblur", "__doPostBack (' LinkButton1 ', ')");
Finally, we need to change the LinkButton text= "Submit" to Text= "", in order to hide LinkButton.