asp.net环境下的链接点击计数--方案3

 文件opus.aspx:

 

<%@ Page Language="C#" AutoEventWireup="true" Inherits="opus" CodeFile="opus.aspx.cs" %>

<%@ Register TagPrefix="cc1" Namespace="LtpPageControl" Assembly="LtpPageControl" %>



    太太乐-关于太太乐
   
   

    <%----%>



   


        <%--       
           
               
           

           
               
           

       
--%>
       

           
               
                    <%--DisplaySWF.aspx?id=<%#Eval("FF_Id") %>--%>
                   

                        <%--/activity/flash/<%#Eval("FF_FileName") %> --%>
                       
" οnclick="Hellow(<%#Eval("FF_Id")%>,<%=Page021.Page_Current %>)" target="_blank">
                            ">
                       

                       

                            " οnclick="Hellow(<%#Eval("FF_Id")%>,<%=Page021.Page_Current %>)"
                                target="_blank">
                                <%#Eval("FF_Description")%>
                           

                       

                   

               

           

           

                            Height="402px" Page_Background="images/bg_38.jpg" Tagp_Background="images/bg_38.jpg">
           

       

   



 

opus.aspx.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.Text.RegularExpressions;
using Maticsoft;
//using System.Web.Services;

public partial class opus : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            InitStatus();
        }
        //根据分页显示
        if (!String.IsNullOrEmpty(Request.Params["Page"] ))
        {
            int current = Convert.ToInt32(Request.Params["Page"].ToString());
            DataBind(current);
            //Page011.Page_Current = current;
            Page021.Page_Current = current;
        }
        else
        {   //显示第1页
            DataBind(1);
        }
        //if (Session["conn"] == null)
        //{
        //    string conn = Maticsoft.DBUtility.DESEncrypt.Decrypt(ConfigurationManager.AppSettings.Get("ConnectionString"));
        //    Session["conn"] = conn;
        //}
    }
    public string GetThumnails(object filename)
    {
        string strFileName = filename.ToString();
        if ((new Regex(".swf")).IsMatch(strFileName))
        {
            return strFileName.Substring(0, strFileName.Length - 4);
        }
        else
            return strFileName;
    }
    ///


    /// 初始化页面状态
    ///

    ///
    ///
    private void InitStatus()
    {
        int iCountPerPage = Convert.ToInt32(ConfigurationManager.AppSettings.Get("CountPerPage"));
        //当配置文件中的CountPerPage为空或非法字符串时,设默认值为10
        if (iCountPerPage == 0) iCountPerPage = 9;
        Tb_FlashFile bll = new Tb_FlashFile();
        int Count = bll.GetCount();
        int PageCount = int.Parse(Math.Ceiling((double)Count / iCountPerPage).ToString());
        //this.Page011.Record_Count = Count;
        //页面总数
        //Page011.Page_Count = PageCount;
        Page021.Page_Count = PageCount;
        //设置每页显示10条记录
        //Page011.Page_Size = iCountPerPage;
        Page021.Page_Size = iCountPerPage;
        //初始化分页界面
        //Page011.Page_Width = 600;
        Page021.PageStep = 1;
        //Page021.Page_Width = 572;
    }
    ///
    /// 绑定数据
    ///

    ///
    private void DataBind(int pageIndex)
    {
        Tb_FlashFile bbl = new Tb_FlashFile();

        DataSet ds = bbl.GetListForFrontByPageIndex(pageIndex);
        //grid.CurrentPageIndex = pageIndex;
        Repeater1.DataSource = ds;
        Repeater1.DataBind();
    }
    //[WebMethod]
    //public static void IncreaseClicks(object FF_Id)
    //{
    //    int id = Convert.ToInt32(FF_Id);
    //    Tb_FlashFile bll = new Tb_FlashFile();
    //    bll.GetModel(id);
    //    bll.FF_Clicks += 1;
    //    bll.Update();

    //}

}

 


(下面的两个文件--CountClick.aspx和CountClick.aspx.cs仅作后台使用,不显示,通过Response.Redirect实现页面加载后即关闭)

CountClick.aspx:

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CountClick.aspx.cs" Inherits="activity_CountClick" %>



    无标题页


   


   

   

   

 

CountClick.aspx.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 Microsoft.VisualBasic;
using Maticsoft;
public partial class activity_CountClick : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.Params["id"] == null ||
                !Information.IsNumeric(Request.Params["id"])) return;
            Tb_FlashFile bbl = new Tb_FlashFile();
            bbl.GetModel(Convert.ToInt32(Request.Params["id"]));
            bbl.FF_Clicks = bbl.FF_Clicks + 1;
            bbl.Update();

            Response.Redirect("opus.aspx?Page=" + Request.Params["Page"]);//通过页面跳转的方式实现页面隐藏,

            //仅仅执行它的后台代码
        }
    }
}

你可能感兴趣的:(asp.net环境下的链接点击计数--方案3)