首页 > 代码库 > ajaxpro实现无刷新更新数据库【简单方法】
ajaxpro实现无刷新更新数据库【简单方法】
原文发布时间为:2008-10-24 —— 来源于本人的百度文章 [由搬家工具导入]
我用的是AjaxPro.2.dll,然后我想点击那个 “无刷新更新” 那个按钮,实现 无刷新 修改表中的内容
{
alert('提交成功');
document.getElementById("Button2").disabled=false;
document.getElementById("Button2").value=http://www.mamicode.com/"无刷新更新";
}
} </script></head><body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /> <br /> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /> <br /> <asp:TextBox ID="TextBox3" runat="server" OnTextChanged="TextBox3_TextChanged"></asp:TextBox><br /> <br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="普通更新" /><br /> <br /> <input id="Button2" type="button" value=http://www.mamicode.com/"无刷新更新" onclick="this.disabled=true;this.value='正在提交当中';return gx()"/>
</form></body></html>
- C# code
- using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;using AjaxPro;public partial class Default2 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(typeof(Default2)); } [AjaxPro.AjaxMethod] public bool gengxin(string u,string p,string s) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["testConn"].ConnectionString); conn.Open(); SqlCommand cmd = new SqlCommand("Proc_UpdateTest", conn); cmd.CommandType = CommandType.StoredProcedure; SqlParameter[] param = new SqlParameter[3]; param[0] = new SqlParameter("@user", SqlDbType.NChar, 10); param[0].Value = http://www.mamicode.com/u; param[1] = new SqlParameter("@paper", SqlDbType.NChar, 10); param[1].Value = p; param[2] = new SqlParameter("@score", SqlDbType.NChar, 10); param[2].Value = s; foreach (SqlParameter Parameter in param) cmd.Parameters.Add(Parameter); cmd.ExecuteNonQuery(); //SqlCommand cmd = new SqlCommand("update Paper set paper='" +p + "',score='" + s+"' where user='" +u + "'",conn); //cmd.ExecuteNonQuery(); conn.Close(); return true; } protected void Button1_Click(object sender, EventArgs e) { gengxin(TextBox1.Text,TextBox2.Text,TextBox3.Text); } protected void TextBox3_TextChanged(object sender, EventArgs e) { }}
ajaxpro实现无刷新更新数据库【简单方法】
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。