随笔:3 文章:0 评论:0 引用:0
博客园 首页 发新随笔
发新文章 联系 订阅订阅管理

2006年9月23日

<script type="text/javascript">

var xmlhttpfunction loadXMLDoc(url)

{

// code for Mozilla, etc.

if (window.XMLHttpRequest)

  {

  xmlhttp=new XMLHttpRequest()

  xmlhttp.onreadystatechange=xmlhttpChange

  xmlhttp.open("GET",url,true)

  xmlhttp.send(null)

  }

// code for IE

else if (window.ActiveXObject)

  {

  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")

    if (xmlhttp)

    {

    xmlhttp.onreadystatechange=xmlhttpChange

    xmlhttp.open("GET",url,true)

    xmlhttp.send()

    }

  }

}

 

function xmlhttpChange()

{

// if xmlhttp shows "loaded"

if (xmlhttp.readyState==4)

  {

  // if "OK"

  if (xmlhttp.status==200)

    {

    // ...some code here...

    }

  else

    {

    alert("Problem retrieving XML data")

    }

  }

}

</script>

posted @ 2006-09-23 16:30 gggcorn 阅读(46) 评论(0) 编辑

2006年9月19日

Ajax.Utility.RegisterTypeForAjax(typeof(AjaxMethod)); if(!Page.IsPostBack) { this.DropDownList1.DataSource=AjaxMethod.GetPovinceList(); this.DropDownList1.DataTextField="province"; this.DropDownList1.DataValueField="provinceID"; this.DropDownList1.DataBind(); this.DropDownList1.Attributes.Add("onchange","cityResult();"); } 用下面的类来操作数据 using System; using System.Data; using System.Data.SqlClient; namespace AjaxTest { /// /// Summary description for AjaxMethod. /// public class AjaxMethod { #region GetPovinceList public static DataSet GetPovinceList() { string sql="select * from province"; return GetDataSet(sql); } #endregion #region GetCityList [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)] public DataSet GetCityList(int povinceid) { string sql="select * from city where father="+povinceid; return GetDataSet(sql); } #endregion #region GetAreaList [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)] public DataSet GetAreaList(int cityid) { string sql="select * from area where father="+cityid; return GetDataSet(sql); } #endregion #region GetDataSet public static DataSet GetDataSet(string sql) { string ConnectionString=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]; SqlDataAdapter sda =new SqlDataAdapter(sql,ConnectionString); DataSet ds=new DataSet(); sda.Fill(ds); return ds; } #endregion } }
posted @ 2006-09-19 14:46 gggcorn 阅读(219) 评论(0) 编辑

2006年7月27日

SqlTransaction st;
   SqlConnection con;
   SqlCommand cmdUpdateA;
   SqlCommand cmdUpdateB;
   con=new SqlConnection("Server=.;database=gggcorn;uid=sa;pwd=");
   cmdUpdateA=new SqlCommand("update data set Datas='"+this.TextBox3.Text+"'where ID=1 ",con);
   cmdUpdateB=new SqlCommand("update data set Datas='"+this.TextBox3.Text+"'where ID=2 ",con);
   con.Open();
   st=con.BeginTransaction();
   cmdUpdateA.Transaction=st;
   cmdUpdateB.Transaction=st;
   try
   {
    cmdUpdateA.ExecuteNonQuery();
    cmdUpdateB.ExecuteNonQuery();
    st.Commit();
    this.Response.Write("<script>alert('success');</script>");
   }
   catch(Exception ex)
   {
    st.Rollback();
    this.Response.Write("<script>alert('fail');</script>");
   }
   finally
   {
    con.Close();
   }
posted @ 2006-07-27 13:09 gggcorn 阅读(113) 评论(0) 编辑
CALENDER
<2012年2月>
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910

公告

公告

    进步是什么?进步是马不停蹄的改造自己,进步是从实践中检验自己!!!!
-----------------------------------
-----------------------------------     Google搜索
昵称:gggcorn
园龄:5年7个月
粉丝:0
关注:8

搜索

 
 

常用链接

随笔分类

随笔档案

asp.net

最新评论


Powered By: 博客园
模板提供沪江博客