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;
using System.Text;
public partial class usercontrol_TopNew : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        GetNewTopTen();
    }
    void GetNewTopTen()
    {
        OleDbDataReader dr = null;
        if (WebClass.GetCache("topTenNew") != null)
        {
            string str = WebClass.GetCache("topTenNew").ToString();
            this.divNewTop.InnerHtml = str;
        }
        else
        {
            try
            {
                string sql = "SELECT TOP 10 * FROM LINKS WHERE SSTATUS = TRUE ORDER BY ID DESC";
                dr = SqlHelper.ExecuteReader(sql);
                StringBuilder sb = new StringBuilder();
                sb.Append("<span style='width:98%;font-weight:bold;'>最新加入网站</span>");
                while (dr.Read())
                {
                    string url = dr["surl"].ToString().Replace("http://", "");
                    sb.AppendFormat("<li><a href=\"http://{0}\" onclick=\"comOut('{1}')\"  target=\"_blank\">{2}</a></li>", url, dr["id"], dr["sname"]);
                }
                this.divNewTop.InnerHtml = sb.ToString();
            }
            catch (Exception ex)
            {
                this.divNewTop.InnerHtml = "读取出错:" + ex.Message;
            }
            finally { if (dr != null) { dr.Close(); dr.Dispose(); } }
        }
    }
}
