When an object loses focus, it moves itself. Implementation code _php skill of submitting data

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.