找回密码
 注册
搜索
热搜: 回贴

用asp.net写的论坛程序

2009-12-13 13:14| 发布者: admin| 查看: 49| 评论: 0|原作者: 云天青

○这是一个用asp.net写的论坛程序,虽......


  这是一个用asp.net写的论坛程序,虽然简单但可以运行。

  这个程序的编程思想其实还是基本延续了asp的方式,如果让那只大鸟儿看见可能要嘘之以鼻。但实际上这种方式对于asp程序向asp.net的快速移植还是有用的。如果你对这种移植不屑那也没办法,这个贴子就算给asp.net刚入门的小虾们开开眼。

这个例子包含3部分

1)forum.aspx-论坛主页。

2)reply.aspx-当在论坛主页中点击一个贴子时调用,显示贴子详细内容。

3)postmessage.aspx-上贴时调用,将内容保存入数据库

数据库结构 Table - newpost :This table will contain the New
Topic posted messages
postid (primary key) The unique id for each new topic.
name The name of the author of the message.
email E-mail address of the author.
subject Subject of the message.
ip IP address of the author.
date Date / Time of the Post
message Message posted.
replies Number of replies to the post (if any)
views Number of times the message has been viewed.


Table - reply :This table will contain the Replies made to the new topics.
replyid (primary key) The unique id for each reply.
name Name of the author.
email E-mail address of the author.
subject Subject of the post
ip IP of the author.
date Date / Time of post.
message Message posted.
postid postid from the "newpost" table for which this message is a reply.


用asp.net写的论坛程序--论坛主页

1) forum.aspx :- The main forum page

<%@ Page Language="C#" Debug="true" %>
<%@ Assembly Name="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System" %>

Welcome to My Forum!


marginheight="0">









<%-- The DataGrid settings. Its very interesting how much you
can play with it --%>
PagerStyle-Mode="NumericPages"
OnPageIndexChanged="DataGrid_Updt" PageSize="20" AllowPaging="True"
width="80%" autogeneratecolumns="False">





















BackColor="Coral">


<%-- I am setting up the Individual columns myself using
Templates --%>

<%-- Manipulate the subject entry so that it contains a link to
the reply page --%>


















































Post New Topic
Name :
*
E-Mail :
*
Subject:
*
Message :
Columns="30" Rows="15" TextMode="MultiLine">

Text="Submit">






用asp.net写的论坛程序--浏览贴子内容及回复

2) reply.aspx : The topic viewing and replying page

<%@ Page Language="C#" EnableSessionState="False" Debug="True" %>
<%@ Import Namespace="System" %>
<%@ Assembly Name="System.Data" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>

Post New Topic.
<%-- These are the imported assemblies and namespaces needed --%>


marginwidth="0" marginheight="0">
<%-- Include a header file 'header.inc' --%>







<%-- Below I am encapsulating the email of the author
over the name of the author
so that when you click on the author a e-mail gets sent to him
Also I am geting the DateTime from the DataBase and
Displaying the Date and Time separately --%>





<%-- Get all the replies to the Original post and show them --%>
<% int no = rs.Tables["reply"].Rows.Count ;
if(no>0)
{
for(int j=0 ;j{
DataRow rd = rs.Tables["reply"].Rows[j] ;
%>




<%
}
}
%>
Author Name Message
<%=
""+dr["name"]+"" %>

<%= dr["date"].ToString().ToDateTime().ToShortDateString() %>

<%= dr["date"].ToString().ToDateTime().ToShortTimeString() %>

Subject: <%=dr["subject"] %>
<%=dr["message"] %>
<%=""+rd["name"]+"" %>

<%= rd["date"].ToString().ToDateTime().ToShortDateString() %>

<%= rd["date"].ToString().ToDateTime().ToShortTimeString() %>

<%=rd["message"] %>


Click Here
to go to back to Forum.

Reply to the Above Post.



























Reply to the Post
Name :
*
E-Mail :
*
Subject:
*
Message :
Columns="30" Rows="15" TextMode="MultiLine">

"server" Text="Submit">







用asp.net写的论坛程序--上贴保存

3) postmessage.aspx :- The page which saved data to the Database


<%@ Import Namespace="System" %>
<%@ Assembly Name="System.Data" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>
<%@ Page Language="C#" Debug="true" %>


Thank You for Posting !



marginwidth="0" marginheight="0">



Thank You , for posting on the Message Board.




















The information You Posted!
Name :
E-Mail :
Subject :
Message :



Click here
to go back to the Forum.

<%-- A little work to show the link to return back to the
page if, the post was a reply --%>
<% if(Request.Params["previd"]!=null)
{ %>

Click here
to go back
where you came from.
<% } %>






最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 05:28 , Processed in 0.202717 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部