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

📄 articlecontent.ascx.cs

📁 内容管理 内容管理 内容管理 内容管理 内容管理
💻 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;

public partial class WebUserControl_ArticleContent : System.Web.UI.UserControl
{
    #region "公共变量"
    /// <summary>
    /// 要执行的sql语句,例如:sql="select * from newsContent";
    /// </summary>
    public string sql = "";


    /// <summary>
    ///   'Param是sql语句条件.例如: order by releaseTime desc
    /// </summary>
    public string Param = "";


    /// <summary>
    /// meWidth是显示控件label1的宽度.例如:meWidth=400
    /// </summary>
    public int meWidth = 0;


    /// <summary>
    /// 网站根目录虚拟路径
    /// </summary>									  
    public string VirtualPath = "";
    #endregion


    protected void Page_Load(object sender, EventArgs e)
    {
        int id = 1;
        if (Request["ID"] != null)
        {
            id = Convert.ToInt32(Request["ID"].ToString());
        }
        getArticleContent(id);
    }


    private void getArticleContent(int ID)
    {
        //在此处放置初始化页的用户代码
        DataSet ds = new DataSet();
        DAL.boBusiness bo = new DAL.boBusiness();
        DAL.MakeConnection Conn = new DAL.MakeConnection();
        DAL.clsDBConnkey ConnKey = new DAL.clsDBConnkey();
        ConnKey = bo.loadkey();//得到config数据库连接


        if (Param != "")
        {
            sql += " " + Param;

        }
        try
        {
            if (ID > 0)
            {
                sql = "Select Top 1 * from  Article where ID=" + ID;
                if (sql != "")
                {
                    ds = (DataSet)Conn.MakeConnectionMethod(sql, ConnKey, DAL.executeMethod.execute_DataSet, DAL.
                        EnumDBType.Sql, VirtualPath);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        string strReader2 = ds.Tables[0].Rows[0]["Content"].ToString();
                        if (meWidth == 0)
                        {
                            meWidth = 600;
                        }
                        this.labArticle.Width = Unit.Pixel(meWidth);
                        this.labTitle.Width = Unit.Pixel(meWidth);
                        this.labTitle.Text = ds.Tables[0].Rows[0]["Title"].ToString();
                        this.labTime.Text = ds.Tables[0].Rows[0]["CreateTime"].ToString();
                        this.labArticle.Text = strReader2;
                    }
                }
            }
        }
        catch (System.Exception ex)
        {
            throw ex;
        }
    }
}

⌨️ 快捷键说明

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