bbscontent.aspx.cs

来自「精通网络应用系统开发 光盘 该书是人民邮电出版社出版的」· CS 代码 · 共 64 行

CS
64
字号
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.Linq;
using System.Collections.Generic;

public partial class DesktopModules_BBS_BBSContent : System.Web.UI.Page
{
    int nTitleID = -1;
    protected void Page_Load(object sender, EventArgs e)
    {   ///获取参数的值
        if (Request.Params["TitleID"] != null)
        {
            nTitleID = Int32.Parse(Request.Params["TitleID"].ToString());
        }
        if (!Page.IsPostBack)
        {   ///绑定控件的数据
            if (nTitleID > -1)
            {
                BindContentData(nTitleID);
                UpdateVisitNum(nTitleID);
            }
        }
    }
    private void BindContentData(int nTitleID)
    {   ///定义类
        ContentM content = new ContentM();
        ///获取数据
        IList<Content> recc = content.GetContentByTitle(nTitleID);
        ///绑定控件的数据
        ContentList.DataSource = recc;
        ContentList.DataBind();
    }
    private void UpdateVisitNum(int nTitleID)
    {
        try
        {
           TitleM title = new TitleM();
            title.UpdateTitleVisitNum(nTitleID);
        }
        catch (Exception ex)
        {   ///显示操作中的失败、错误信息
            Response.Redirect("~/DesktopModules/ErrorPage.aspx?ErrorUrl="
                + ASPNET35System.RedirectErrorUrl(Request.RawUrl)
                + "&ErrorMessage=" + ex.Message.Replace("\n", " "));
        }
    }
    protected string FormatBody(string sBody)
    {
        return (sBody.Replace("\n", "<br>"));
    }


}

⌨️ 快捷键说明

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