⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ajaxmethod.aspx.cs

📁 ajax 实现仿照 igoogle的界面
💻 CS
字号:
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.OleDb;
public partial class googlei_ajaxmethod : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string name1 = Request.QueryString["keyword"];
        string name = "";
        name = name1.Substring(0, 1);

            switch( Convert.ToInt32(name.Trim()))//1-获得类别数
            {
                case 1:
                    
                    Response.Write(getclassname());
                    break;

                case 2:
                    Response.Write(getdata(name1.Substring(1, 1)));
                    break;
                case 3:
                    Response.Write(gettext(name1.Substring(1, 1)));
                    break;
                case 4:
                    Response.Write(addcount(name1.Substring(1, 1)));
                    break;



            }


    }
    /*  * */
    private string addcount(string id)
    {
        try
        {
            OleDbConnection conn = getdb();
            conn.Open();
            OleDbCommand oc = new OleDbCommand();
            string res = "";
            string sql1 = "update ttt set tcount=tcount+1 where tnum=" + id;
            oc.CommandText = sql1;
            oc.Connection = conn;
            oc.ExecuteNonQuery();

            string sql = "select tcount from ttt where tnum=" + id;
            oc.CommandText = sql;
            OleDbDataReader ob = oc.ExecuteReader();
            if (ob.Read())
            {
                res = ob.GetInt32(0).ToString();
            }
            return res;
        }
        catch (Exception ee)
        {
            return ee.ToString();
        }

    }
   
    private string  gettext(string id)
    {
        OleDbConnection conn = getdb();
        conn.Open();
        OleDbCommand oc = new OleDbCommand();
        string res = "";
        string sql = "select tt,tcount from ttt where tnum="+id;

        oc.CommandText = sql;
        oc.Connection = conn;
        OleDbDataReader ob = oc.ExecuteReader();
        if (ob.Read())
        {
            res =  ob.GetString(0);
            res = res + "&*&*" + ob.GetInt32(1);
        }
        return res;
    }
    private string getclassname()
    {
        OleDbConnection conn = getdb();
        conn.Open();
        OleDbCommand oc = new OleDbCommand();
        string res="";
        string sql = "select name from temp";

        oc.CommandText = sql;
        oc.Connection = conn;
        OleDbDataReader ob = oc.ExecuteReader();
        while (ob.Read())
        {
            res = res + ob.GetString(0);
            res = res + ";";
        }
        return res;
    }

    private string getdata(string id)
    {
        int i = 0;
        string all="";
        for (i = 1; i <= Convert.ToInt32(id); i++)
        {
            all = all + getd(i.ToString());
            all = all + "*";
        }
        return all;

    }
    private string getd(string id)
    {
        try
        {
            OleDbConnection conn = getdb();
            conn.Open();
            OleDbCommand oc = new OleDbCommand();
            string res = "";
            string sql = "select aid,atitle from art where anum=" + id;
            string temp = "";
            oc.CommandText = sql;
            oc.Connection = conn;
            OleDbDataReader ob = oc.ExecuteReader();
            while (ob.Read())
            {
                temp = ob.GetInt32(0).ToString() + "&" + ob.GetString(1);
                res = res + temp;
                res = res + ";";
            }
            conn.Close();
            return res;
        }
        catch (Exception ee)
        {
            return ee.ToString(); ;
        }
    }

    private OleDbConnection getdb()
    {
            OleDbConnection conn = new OleDbConnection();
            conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
                    @"Data source=" + Server.MapPath("db.mdb");
            return conn;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -