zoukankan      html  css  js  c++  java
  • ajaxpro实现无刷新更新数据库【简单方法】

    原文发布时间为:2008-10-24 —— 来源于本人的百度文章 [由搬家工具导入]

    我用的是AjaxPro.2.dll,然后我想点击那个 “无刷新更新” 那个按钮,实现 无刷新 修改表中的内容

    HTML code
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!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> <script type="text/javascript"> function gx() { var u=document.getElementById("TextBox1").value; var p=document.getElementById("TextBox2").value; var s=document.getElementById("TextBox3").value; Default2.gengxin(u,p,s,callback); } function callback(res) { if(res.value==true)
          {
              alert('提交成功');         
              document.getElementById("Button2").disabled=false;
              document.getElementById("Button2").value="无刷新更新";
       }
          } </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 />         &nbsp;<input id="Button2" type="button" value="无刷新更新" onclick="this.disabled=true;this.value='正在提交当中';return gx()"/></div>
    </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 = 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) { }}
  • 相关阅读:
    JAVA多线程之守护线程
    有符号数与无符号数
    子母钟系统,GPS时钟系统,医院网络时间同步技术方案
    NTP时间同步服务器,GPS时钟系统,北斗授时产品,京准科技
    卫星时钟系统(NTP网络时钟系统)技术应用方案
    GPS对时产品,NTP校时,时间同步服务器,北斗授时设备
    GPS对时装置(NTP时钟服务器)应用安防监控系统
    考场时钟系统(标准化考场时钟同步建设)应用方案
    时间同步装置(GPS时钟)在电网SCADA系统应用
    网络时间服务器(医院时钟系统)相关问题汇总
  • 原文地址:https://www.cnblogs.com/handboy/p/7148455.html
Copyright © 2011-2022 走看看