动态网站制作指南 [  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP实例
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ ASP实例 ]的信息

本月文章推荐
.ASP环境下邮件列表功能的实现 (.
.经典的分页完整程序+注释.
.一个漂亮的点击计数器.
.用Web页面执行客户端程序.
.XMLHTTP+Javascript+Asp写得聊天.
.天气预报的小偷,可以偷到全国24小.
.多图片上传到指定的目录并存到数.
.Execel文件插入到ASP页面.
.一个利用adsi得到局域网信息的as.
.综合的判断用户输入的合法性的函.
.轻松打造ASP计数器.
.Win2k IIS 远程执行命令漏洞.
.用asp实现的代码批量修改程序.
.无刷新随时取得用户当前活动信息.
.采用XMLHTTP编写一个天气预报的程.
.ASP连接执行程序 .
.ASP.NET: XML计数器第二版.
.ASP+VML+DB实现投票统计项目.
.使用 ASP+ 列表绑定控件(下).
.汉字转化为拼音.

asp+的论坛列表程序---代码部分

发表日期:2000-12-4 |


asp+的论坛列表程序---代码部分    

--------------------------------------------------------------------------------
【bigeagle】 于 2000-11-13 15:38:57 加贴在 Joy ASP ↑:

///////////////////////////////////////////////////////////////////////////////
//
// File name:         forum.cs
//
// Description:       forum.aspx的后台代码
//
// date:              2000/10/13
//
// Programming:       Bigeagle
//
// History:           version 1.0
//                    start at 2000/10/13 16:45  finish
//
////////////////////////////////////////////////////////////////////////////////



using System;
using System.Collections ;
using System.Data;
using System.Data.SQL;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Drawing ;

public class Forum : Page
{
  

  //public Image imgIfNew ;
  public Label lblForumName ;
  public HyperLink linkMaster ;
  public Label lblForumName1 ;
  public ImageButton btnPostNew ;
  public ImageButton btnPostNew1 ;
  public Label lblTopicCounts ;
  public Label lblTopicCounts1 ;
  public Label lblPerPage ;
  public Label lblPosition ;
  public HtmlImage imgOICQ ;
  public HyperLink linkFirstPage ;
  public HyperLink linkPrevPage ;
  public HyperLink linkNextPage ;
  public HyperLink linkLastPage ;
  public HyperLink linkFirstPage1 ;
  public HyperLink linkPrevPage1 ;
  public HyperLink linkNextPage1 ;
  public HyperLink linkLastPage1 ;
  public DropDownList selChangeForum ;       //转换版面下拉框
  
  public Table tblTopic ;
  
  public void Page_Load(Object sender , EventArgs e)
    {
      Int32 intForumID = new Int32();
      Int32 intPageNo  = new Int32() ;      
      int intPageSize  = 20 ;
      int intPageCount = 0 ;
      int intTopicCounts = 0 ;
     
     
     //--edit by bigeagle 2000/10/25------------------
     // if (Session["LoginID"] == null )
     //   {
     //       Response.Redirect("login.aspx") ;
     //   }
     //-----------------------------------------------
     
      //接收论坛ID
      try
        {
          intForumID = Request.QueryString["ID"].ToInt32() ;
        
        }
      catch(Exception exp)
        {
          Response.Write(exp.ToString()) ;
        }  
      
      GetForumInfo(intForumID) ;
      
      //接收页号
      try
        {
          intPageNo = Request.QueryString["PageNo"].ToInt32() ;
        
        }
      catch(Exception exp)
        {
          intPageNo = 1 ;
        }  
      
      //规范页号,页数
      intTopicCounts = lblTopicCounts1.Text.ToInt32() ;
      if (intTopicCounts <= intPageSize)
        {
          intPageCount = 1 ;
        }
      else if (intTopicCounts / intPageSize == 0)
        {
          intPageCount = intTopicCounts / intPageSize ;
        }
      else
        {
          intPageCount = (int)(intTopicCounts / intPageSize) + 1 ;   
        }
      
      if (intPageNo < 1)
        {
          intPageNo = 1 ;
        }
      else if (intPageNo > intPageCount)
        {
          intPageNo = intPageCount ;
        }         
        
      //初始化页面显示
      lblTopicCounts.Text      = intTopicCounts.ToString() ;
      lblTopicCounts.ForeColor = Color.Green ;
      lblPerPage.Text          = intPageSize.ToString() ;
      lblPerPage.ForeColor     = Color.Green ;
      lblPosition.Text         = intPageNo.ToString() + "/" + intPageCount.ToString() ;
      lblPosition.ForeColor    = Color.Green ;
      
      
      //更新导航栏
      
      //首页
      if (intPageNo != 1)
        {
          linkFirstPage.NavigateUrl = "forum.aspx?" + "ID=" + intForumID.ToString() ;
          linkFirstPage.ToolTip     = "回到首页" ;
          linkFirstPage1.NavigateUrl = "forum.aspx?" + "ID=" + intForumID.ToString() ;
          linkFirstPage1.ToolTip     = "回到首页" ;
        }
      else
        {
          linkFirstPage.ToolTip     = "你现在就在首页。" ;
          linkFirstPage1.ToolTip     = "你现在就在首页。" ;
        }     
                                          
     //前页
     if (intPageNo > 1 )
        {
          linkPrevPage.NavigateUrl = "forum.aspx?" + "ID=" + intForumID.ToString()
                                    + "&PageNo=" + (intPageNo - 1).ToString() ;
          linkPrevPage.ToolTip     = "回到上一页。" ;
          linkPrevPage1.NavigateUrl = "forum.aspx?" + "ID=" + intForumID.ToString()
                                    + "&PageNo=" + (intPageNo - 1).ToString() ;
          linkPrevPage1.ToolTip     = "回到上一页。" ;
        }
     else
        {
          linkPrevPage.ToolTip     = "你现在就位于第一页,你还想上哪儿?" ;
          linkPrevPage1.ToolTip     = "你现在就位于第一页,你还想上哪儿?" ;
        }
     
     //后页
     if (intPageNo < intPageCount )
       {
         linkNextPage.NavigateUrl  = "forum.aspx?" + "ID=" + intForumID.ToString()
                                    + "&PageNo=" + (intPageNo + 1).ToString() ;
         linkNextPage.ToolTip      = "到下一页。" ;
         linkNextPage1.NavigateUrl  = "forum.aspx?" + "ID=" + intForumID.ToString()
                                    + "&PageNo=" + (intPageNo + 1).ToString() ;
         linkNextPage1.ToolTip      = "到下一页。" ;
       }
     else
       {
         linkNextPage.ToolTip      = "你现在就位于最后一页,你还想上哪
儿?" ;                                                                               
         linkNextPage1.ToolTip      = "你现在就位于最后一页,你还想上哪
儿?" ;                                                                               
       }
       
     //末页
     if (intPageNo != intPageCount)
       {
         linkLastPage.NavigateUrl  = "forum.aspx?" + "ID=" + intForumID.ToString()
                                    + "&PageNo=" + intPageCount.ToString() ;
         linkLastPage.ToolTip      = "到最后一页。" ;
         linkLastPage1.NavigateUrl  = "forum.aspx?" + "ID=" + intForumID.ToString()
                                    + "&PageNo=" + intPageCount.ToString() ;
         linkLastPage1.ToolTip      = "到最后一页。" ;
       }
     else
       {
         linkLastPage.ToolTip      = "你现在就位于最后一页。" ;
         linkLastPage1.ToolTip      = "你现在就位于最后一页。" ;
       }                                 
        
        
      //贴子列表
      ShowTopicList(intForumID , 0 , intPageNo , intPageSize) ;
      
      //显示转换版面下拉列表
      ShowChangeForum(intForumID) ;
    }

  private void ShowTopicList(int a_intForumID , int a_intDays , int a_intPageNo , int a_intPageSize)
    {
      
      //读出纪录
      SQLConnection myConnection = new SQLConnection("server=server1;uid=sa;pwd=;database=BBS");
      SQLCommand myCommand = new SQLCommand("up_TopicsList" , myConnection);

      myCommand.ActiveConnection = myConnection ;
      myCommand.CommandType = CommandType.StoredProcedure;
      
      SQLParameter workParam = null;

      //论坛id
      workParam = myCommand.Parameters.Add(new SQLParameter("@a_ForumID", SQLDataType.Int, 4));
      workParam.Direction = ParameterDirection.Input;
      workParam.Value = a_intForumID ;
        
         
      //限定天数
      workParam = myCommand.Parameters.Add(new SQLParameter("@a_intDays", SQLDataType.Int, 4));
      workParam.Direction = ParameterDirection.Input;
      workParam.Value = a_intDays ;
      
      //页号
      workParam = myCommand.Parameters.Add(new SQLParameter("@a_intPageNo", SQLDataType.Int, 4));
      workParam.Direction = ParameterDirection.Input;
      workParam.Value = a_intPageNo ;
      
      //每页显示数
      workParam = myCommand.Parameters.Add(new SQLParameter("@a_intPageSize", SQLDataType.Int, 4));
      workParam.Direction = ParameterDirection.Input;
      workParam.Value = a_intPageSize ;
      
      SQLDataReader myReader ;

      try
        {
          myConnection.Open();
          myCommand.Execute(out myReader);
          //Response.Write(myReader.HasValue.ToString());
          
          //取纪录
          if (lblTopicCounts.Text.ToInt32() == 0)        //如果没有发言
            {
              TableRow tr = new TableRow() ;
              tr.BackColor = Color.White ;
              TableCell td = new TableCell() ;
              td.ColumnSpan = 6 ;
              td.VerticalAlign = VerticalAlign.Middle ;
              td.HorizontalAlign = HorizontalAlign.Center ;
              td.Height  =200 ;
              td.Controls.Add(new LiteralControl("目前尚未有人发言!")) ;
              tr.Cells.Add(td) ;
              tblTopic.Rows.Add(tr) ;
            }
          else                                         //否则,显示贴字列表
            {   
              
              while (myReader.Read())
                {
                  String strInnerHtml = "";
                  TableRow tr = new TableRow() ;
                  tr.BackColor = Color.White ;
                  
                  //贴子状态图片
                  TableCell tdStatus = new TableCell() ;
                  if ((int)myReader["TotalChilds"] == 0)
                    {
                      strInnerHtml = "<img src='images/closed.gif' alt='没有新回复。'>" ;
                    }
                  else if((int)myReader["TotalChilds"] < 5)
                    {
                      strInnerHtml = "<img src='images/closedb.gif' alt='有新回复,不过不多。'>";
                    }
                  else if((int)myReader["TotalChilds"] >= 10)
                    {
                      strInnerHtml = "<img src='images/hotclosedb.gif' alt='太火了。'>";
                    }                    
                  else if((int)myReader["TotalChilds"] >= 5)
                    {
                      strInnerHtml = "<img src='images/hotclosed.gif' alt='回复不少。'>";
                    }
                  tdStatus.Controls.Add(new LiteralControl(strInnerHtml)) ;
                  tr.Cells.Add(tdStatus) ;
                  
                  //表情图片
                  TableCell tdFace = new TableCell() ;
                  strInnerHtml = "<img src='images/icon"+myReader["FaceID"].ToString() +".gif'>" ;
                  //Response.Write(strInnerHtml) ;
                  tdFace.Controls.Add(new LiteralControl(strInnerHtml)) ;
                  tr.Cells.Add(tdFace) ;
                  
                  //主题
                  TableCell tdTitle = new TableCell() ;
                  strInnerHtml = "<a href='ShowTopic.aspx?id=" + myReader["ID"].ToString() + "'>"
                                + myReader["Title"].ToString()  + "</a>";
                  tdTitle.Controls.Add(new LiteralControl(strInnerHtml)) ;
                  tr.Cells.Add(tdTitle) ;
                  
                  //作者
                  TableCell tdAuthor = new TableCell() ;
                  strInnerHtml = myReader["UserName"].ToString() ;
                  tdAuthor.Controls.Add(new LiteralControl(strInnerHtml)) ;
                  tr.Cells.Add(tdAuthor) ;
                  
                  //回复数
                  TableCell tdReply = new TableCell() ;
                  strInnerHtml = myReader["TotalChilds"].ToString() ;
                  tdReply.Controls.Add(new LiteralControl(strInnerHtml)) ;
                  tr.Cells.Add(tdReply) ;
                  
                  //最后回复时间
                  TableCell tdReplyTime = new TableCell() ;
                  strInnerHtml = myReader["LastReplyTime"].ToString() ;
                  tdReplyTime.Controls.Add(new LiteralControl(strInnerHtml)) ;
                  tr.Cells.Add(tdReplyTime) ;
                  
                  tblTopic.Rows.Add(tr) ;
                  
                  
                  
                  
                }
            }
        }
      catch(Exception exp)
        {
          Response.Write(exp.ToString() ) ;
          //Response.Redirect("error.asp") ;
        }
      finally
        {
          myConnection.Close();
          //Response.Redirect("default.aspx") ;
        }                
      
      
    }
    
  private void GetForumInfo(int a_intForumID)
    {
      SQLConnection myConnection = new SQLConnection("server=server1;uid=sa;pwd=;database=BBS");
      SQLCommand myCommand = new SQLCommand("up_GetForum" , myConnection);

      myCommand.ActiveConnection = myConnection ;
      myCommand.CommandType = CommandType.StoredProcedure;
      
      SQLParameter workParam = null;

      //论坛id
      workParam = myCommand.Parameters.Add(new SQLParameter("@a_ForumID", SQLDataType.Int, 4));
      workParam.Direction = ParameterDirection.Input;
      workParam.Value = a_intForumID ;
        
         

      
      SQLDataReader myReader ;

      try
        {
          myConnection.Open();
          myCommand.Execute(out myReader);
          
          myReader.Read() ;
          
          //板块名称
          lblForumName.Text  = myReader["CategoryName"].ToString() ;       
          lblForumName.CssClass = "BigTitle" ;
          lblForumName.ToolTip = myReader["Description"].ToString() ;
          lblForumName1.Text = lblForumName.Text ;
          lblForumName1.CssClass = "Title" ;
          lblForumName1.ToolTip = myReader["Description"].ToString() ;

          //贴子数
          lblTopicCounts1.Text = myReader["NewTopicNumber"].ToString() ;
          lblTopicCounts1.ToolTip = "当前贴子数:" + lblTopicCounts1.Text ;


          //oicq
          if (myReader["OICQ"].ToString() != "")
            {
              imgOICQ.Src = "http://infocenter.tencent.com/" + myReader["OICQ"].ToString() + "/s/00/99" ;
              imgOICQ.Alt = "OICQ:" + myReader["OICQ"].ToString() ;
              //imgOICQ.Src = "images/off.gif" ;
            }
          else
            {
              imgOICQ.Src = "" ;
              imgOICQ.Alt = "没留OICQ。" ;
            }    

          //版主
          linkMaster.Text = myReader["UserName"].ToString() ;
          linkMaster.NavigateUrl = (myReader["Email"].ToString() == "" ? "" :
                                  "MailTo:" + myReader["Email"].ToString()) ;
          linkMaster.ToolTip = (myReader["Email"].ToString() == "" ? "版主没留Email," :"写信给版主,");
          
        }
      catch(Exception exp)
        {
          Response.Write(exp.ToString()) ;
          //Response.Redirect("error.asp") ;
        }
      finally
        {
          myConnection.Close();
          //Response.Redirect("default.aspx") ;
        }    
    
   }
   
  //显示转换版面下拉列表
  private void ShowChangeForum(int a_intForumID)
   {
     selChangeForum.Width = 200 ;
     
   }  
}   

上一篇:用多种方法制作WEB页面的计数器 人气:10226
下一篇:asp+的论坛列表程序---页面部分 人气:10144
浏览全部的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-11-19 老Y文章管理系统 v2.2 bulid 081
2008-11-19 仿webmasterhome 网站收录查询 v
2008-11-19 小计天空儿童教育网站 v1.0
2008-11-19 小计天空儿服装企业网站 v1.0
2008-11-19 FLV地址解析小偷
2008-11-19 开良马克思影视下载插件 v1.0
2008-11-18 bbclone v0.4.9c 多国语言版
2008-11-18 雪晖在线投票系统 (asp) Build 2
2008-11-18 Piwik ( PHP统计系统,可以和GOOG
2008-11-15 BitTorrent 6.1.2 Build 13185
2008-11-15 BitComet 1.06
2008-11-15 SpeedFan 4.36 Final
2008-11-15 Windows Installer CleanUp Util
2008-11-15 Safari 3.2
2008-11-15 RealPlayer 11.0.0.835 简体中文
2008-11-15 QQ for Mac Preview 3 Build 394
2008-11-15 Vista优化大师3.20
2008-11-15 酷点 CoolDock 0.6
  发表评论
姓 名: 验证码:
内 容:
站长工具:网站收录查询 | Google PR查询 | ALEXA排名查询 | CSS在线编辑器 | 广告代码 | js/vbs加密 | md5加密 | 进制转换 | UTF-8 转换工具 | Html转换js | Html转换asp | Html转换php | Html转换perl
实用工具:汉字翻译拼音 | 拼音字典 | 符号对照表 | 个税计算 | 实时汇率查询换算 | 经典小工具 | 汉字简繁转换 | 普通单位换算 | 公制单位换算 | 生辰老黄历 | 国内电话区号 | 国家代码与域名缩写 | 文字加密解密 | 健康查询 | 万年历 | 汉字横竖排版 | 手机号码查询 | 计算器 | ip搜索
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号
ホームページ制作 不動産検索システム 求人情報
防水工事·改修工事 フットサル大会 探偵
SEO対策 中国語教室 ホームページ作成