asp.net留言板管理源代码

 页面代码:

<body>
    <form id="form1" runat="server">
        <asp:DataList ID="ImageList" runat="server" RepeatDirection="Vertical" Width="500px" CellPadding="0">
            <ItemTemplate>
                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                        <td style="padding-left: 10px; height: 20px;">
                            留言称呼:<%# Eval("F_Name")%>(<%# Eval("F_AddTime")%>)
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left: 10px; height: 20px;">
                            留言主题:<%# Eval("F_Title")%>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left: 10px; height: 20px; width: 500px; word-break: break-all; word-wrap: break-word;">
                            留言内容:<%# Eval("F_Book")%>
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 5px;">
                            <div style="border-width: 2px; border-style: dashed none none none; border-color: #AB7D49; height: 4px;">
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:DataList>
    </form>
</body>

 

---------------------------------------------------------------------------------------------------------------------------------------------------------------

 

关键代码:

///**************************
/// 创 建 者:Bonnibell
/// 创建日期:2008-11-20
/// 所属模块:留言板
/// 功  能:
/// 接受参数:
/// 含数据表:
///**************************
using System;
using System.Data;
using System.Data.OleDb;
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;

public partial class Book_Get : System.Web.UI.Page
{
    string strConn = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString;

    string s_CurrentPage = string.Empty;
    string s_PageCount = string.Empty;
    string s_RecordCount = string.Empty;

    int i_CurrentPage = 0;
    int i_PageCount = 0;
    int i_RecordCount = 0;


    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["PageIndex"] != null)
        {
            if (!string.IsNullOrEmpty(Request.Params["PageIndex"]))
            {
                s_CurrentPage = Request.Params["PageIndex"].ToString();
                i_CurrentPage = Int32.Parse(s_CurrentPage);
            }
        }
        BindDateList();
    }

    string GetName(string strIN)
    {
        string strTemp = strIN;

        if (strTemp.Length > 10)
        {
            strTemp = strTemp.Substring(0, 10);
        }
        return strTemp;
    }

    void BindDateList()
    {
        string strSql_Count = "Select Count(*) from T_Book";
        s_RecordCount = SqlHelper.ExecuteScalar(strConn, strSql_Count, null).ToString();
        i_RecordCount = Convert.ToInt32(s_RecordCount);

        if (i_RecordCount % 10 > 0)
        {
            i_PageCount = i_RecordCount / 10 + 1;
        }
        else
        {
            i_PageCount = i_RecordCount / 10;
        }

        s_PageCount = i_PageCount.ToString();

        string strRecordTemp = string.Empty;
        strRecordTemp = Convert.ToString(i_CurrentPage * 10);
        string strSql = string.Empty;

        if (s_CurrentPage == "0")
        {
            strSql = "select top 10 F_Name,F_Title,F_AddTime,F_Book  from T_Book order by F_Code DESC";
        }
        else
        {
            strSql = "select top 10 F_Name,F_Title,F_AddTime,F_Book from T_Book  where F_Code not in (select top " + strRecordTemp + " F_Code from T_Book order by F_Code DESC) order by F_Code DESC";
        }
        OleDbDataReader Rdlist = SqlHelper.ExecuteReader(strConn, strSql, null);
        DataTable Dt = new DataTable();
        DataRow dr;
        Dt.Columns.Add("F_Name", typeof(string));
        Dt.Columns.Add("F_Title", typeof(string));
        Dt.Columns.Add("F_AddTime", typeof(string));
        Dt.Columns.Add("F_Book", typeof(string));

        while (Rdlist.Read())
        {
            dr = Dt.NewRow();
            dr[0] = Rdlist[0].ToString();
            dr[1] = Rdlist[1].ToString();
            dr[2] = Rdlist[2].ToString();
            dr[3] = Rdlist[3].ToString();
            Dt.Rows.Add(dr);
        }
        Rdlist.Close();
        this.ImageList.DataSource = new DataView(Dt);
        this.ImageList.DataBind();
    }
    protected override void Render(HtmlTextWriter writer)
    {

        if (i_RecordCount > 0)
        {
            StringBuilder sp = new StringBuilder();
            sp.AppendLine("<table border=/"0/" cellpadding=/"0/" cellspacing=/"0/" width=/"300px/" >");
            sp.AppendLine("<tr>");
            sp.AppendLine(" <td>&nbsp;&nbsp;&nbsp;&nbsp;共&nbsp;");
            sp.Append(s_RecordCount);
            sp.AppendLine("&nbsp;条记录");
            sp.AppendLine("   </td>");
            sp.AppendLine(" <td style=/"padding-top:3px;/">");
            if (i_PageCount > 1)
            {
                if (i_CurrentPage == 0)
                {
                    sp.AppendLine("<a  href=/"javascript:Paging(" + Convert.ToString(i_CurrentPage + 1) + ")/" style=/"display:inline-block;color:#ffffff;text-decoration:none;height:17px;/">下一页</a>");
                    sp.AppendLine("&nbsp;");
                    sp.AppendLine("<a  href=/"javascript:Paging(" + Convert.ToString(i_PageCount - 1) + ")/" style=/"display:inline-block;color:#ffffff;text-decoration:none;height:17px;/">末页</a>");
                    sp.AppendLine("&nbsp;&nbsp;");
                }
                else
                {
                    if (Convert.ToInt32(i_CurrentPage + 1) == i_PageCount)
                    {
                        sp.AppendLine("<a  href=/"javascript:Paging(0)/" style=/"display:inline-block;color:#ffffff;text-decoration:none;height:17px;/">首页</a>");
                        sp.AppendLine("&nbsp;");
                        sp.AppendLine("<a  href=/"javascript:Paging(" + Convert.ToString(i_CurrentPage - 1) + ")/" style=/"display:inline-block;color:#ffffff;text-decoration:none;height:17px;/">上一页</a>");
                        sp.AppendLine("&nbsp;");
                    }
                    else
                    {
                        sp.AppendLine("<a  href=/"javascript:Paging(0)/" style=/"display:inline-block;color:#ffffff;text-decoration:none;height:17px;/">首页</a>");
                        sp.AppendLine("&nbsp;");
                        sp.AppendLine("<a  href=/"javascript:Paging(" + Convert.ToString(i_CurrentPage - 1) + ")/" style=/"display:inline-block;color:#ffffff;text-decoration:none;height:17px;/">上一页</a>");
                        sp.AppendLine("&nbsp;");
                        sp.AppendLine("<a  href=/"javascript:Paging(" + Convert.ToString(i_CurrentPage + 1) + ")/" style=/"display:inline-block;color:#ffffff;text-decoration:none;height:17px;/">下一页</a>");
                        sp.AppendLine("&nbsp;");
                        sp.AppendLine("<a  href=/"javascript:Paging(" + Convert.ToString(i_PageCount - 1) + ")/" style=/"display:inline-block;color:#ffffff;text-decoration:none;height:17px;/">末页</a>");
                        sp.AppendLine("&nbsp;&nbsp;");
                    }
                }
            }
            sp.AppendLine(" </td>");
            sp.AppendLine(" <td>");
            sp.AppendLine("<span >共" + s_PageCount + "页,当前第" + Convert.ToString(i_CurrentPage + 1) + "页</span>");
            sp.AppendLine(" </td>");
            sp.AppendLine("</tr>");
            sp.AppendLine("</table>");

            writer.Write(sp.ToString());
        }
        this.ImageList.RenderControl(writer);
    }
}

 

  • 3
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
ASP.NET留言 Version 1.0 软件信息: 软件名称:光辉岁月留言 版 本 号:Version 1.0 授权类型:免费软件 运行环境:ASP.NET 版权所有:光辉岁月 Q Q:258653163 开发日期:2007.1 软件描述: 1、使用ASP.NET(C#)开发; 2、全部代码都由手写完成,清晰易懂、易维护; 3、采用三层体系结构,通过接口继承来支持多数据库模式; 4、动态支持Access,MSSQL(存储过程); 5、支持HTML编辑器,集成QQ,MSN,TAOBAO等表情; 版权声明: 1. 本软件由本人独立开发完成的留言平台,拥有留言簿的所有版权。 2. 本软件为免费软件,授权用户免费使用,无须通告作者本人。 3. 允许任何人可以在本软件的基础上独立开发新的模块,并可自由商业或免费,并不受限制。 4. 本软件使用了部分网络上的资源(包括图像,皮肤等)。如果您有任何意见或想法可以与我取得联系 。我将会根据您的意愿进行修改。 免责声明: 1.本软件是免费软件,作者只负责软件本身的制作与维护,不负责任何与软件本身无关的问题。 2.用户自愿使用本软件,并无须支付任何费用,由使用软件对用户所造成的任何损失均与作者无关。 3.用户在使用本软件时所引起的任何纠纷均与作者无关。 4.浏览者发表的任何言论,纯属浏览者个人意见,概与作者无关。 5.用户使用本软件,即表示无条件接受以上条款。 6.作者保留以上条款的最终解释权。 安装使用: Access环境 前提必须支持asp.net 注意:你电脑的系统必须装了Internet 服务管理器和Microsoft.NET Framework 1.1或2.0 双击Setup.exe应用文件,然后进行安装。然后进入C:\\Inetpub\\wwwroot\\BBS里面的#chat.mdb数据拿出来 到C:\\ 数据库的路径可以在Web.config里面的以下改: <add key=\"connString\" value=\"Provider=Microsoft.Jet.OleDb.4.0;Data Source=C:\\#chat.mdb\"></add> 最后就可以在IE里面的地址栏上输入http://localhost/bbs运行出来了。 ****************************************************************************************** 注意:请不要直接进入数据库更改密码,因为数据库已经通过MD5的数据加过密,要更改密码,请用默认 的系统管理员帐号和密码登录,进去可以更改,要是你直接进数据库自己改的会,可能会出现不能登录的 问题。 ****************************************************************************************** 默认系统管理员帐号:admin 默认系统管理员密码:admin 常见问题: 如果出现未设置对象实例,无法添加记录,DBNULL转换失败等错误,可能是数据库遭到破坏,如果是NTFS分区 ,最好将数据库文件的EVERYONE用户的所有权限设置为允许 与我联系: QQ:258653163 官方主页: http://www.ghsy123.com 电子邮件: pyh123@126.com 2007.2

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值