All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
最近收集的有用的Javscript小技巧_JavaScript技术_编程技术
动态网页技巧:PHP,MySQL,integration_php资料_编程技术
配置ASP.net的运行环境_[Asp.Net教程]
SQL初学者教程:掌握SQL DELETE 语句_[SQL Server教程]
mssql存储过程类型详解_mssql学习_编程技术
查询同一表内多字段同时重复记录的SQL语句_[SQL Server教程]
C#中程序调试之终止执行
WML学习(三)-显示文本_[XML教程]
用PHP实现自动把纯文本转换成Web页面_php资料_编程技术
C#关闭Windows,XP的实现代码_.net资料_编程技术
Reading number is top 10 pictures
The money of more than 100 countries and regions14
9.3阅兵全景图5-地空反舰导弹梯队
美女浴室写真3
代沟,真好
Summer is most suitable for young people to travel in China2
男人帮杂志里的惹火性感美女2
徐若瑄展示美丽胸围2
yy365网站上的美女3
身材野火台灣美女1
The money of more than 100 countries and regions16
Download software ranking
Unix video tutorial19
实战黑客不求人
小黑猫大战两米大花蛇
Ashlynn Video1
Unix video tutorial3
Boxer vs Yellow3
matrix2
在线棋牌游戏3.05版
电车之狼R
传奇私服架设教程-chm
aaa published in(发表于) 2013/12/13 9:43:16 Edit(编辑)
如何建立自己的新闻发布系统?_.net资料_编程技术

如何建立自己的新闻发布系统?_.net资料_编程技术

如何建立自己的新闻发布系统?_.net资料_编程技术-你的首页-uuhomepage.com
下面是一个建立新闻发布系统的程序,不用和数据库打交道哦
步骤:
(1).在vs2005中新建网站,新建三个aspx网页,分别命名:title.aspx,news.aspx,main.aspx其中title.aspx用来设置标题,可以自己设计,写几个字也行,news.aspx用来显示新闻标题,main.aspx用来显示新闻内容。
(2).新建htm页,用来设计框架。代码如下:
http://www.w3.org/1999/xhtml" >

无标题页








(3).现在你的程序还没有内容,新建xml文件,命名contents.xml,用来显示新闻标题,代码如下:



欢迎进入千里之外的新闻网!
main.aspx?name=hello


测试新闻
main.aspx?name=test


第一条新闻
main.aspx?name=first


第二条新闻
main.aspx?name=dddd
注意我们的每条新闻内容都是一个xml文件,现在你知道该做什么了吧,新建hello.xml;test.xml;first.xml;dddd.xml文件,在这里给出一个例子,代码如下:


今日新闻
头版新闻
千里之外
<paragraph>大家好</paragraph>
现在你就可以看到效果了,下面我们看一下发布新闻的代码,也很简单,新建manage.aspx页面,前台代码:





千里之外个人新闻发布系统


文件名:

(必要栏)


文章名称:

(必要栏)


作者:

(必要栏)


摘要:




内容:








后台代码如下:
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;
using System.IO;
using System.Xml;
public partial class manage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//判断文件是否存在
if (File.Exists(Server.MapPath(TextBox1.Text + ".xml")))
Response.Write("文件名已经存在,请重新选文件名!");
else
{
//首先将数据插入新闻列表中
XmlNode CurrNode;
XmlDocument xmldoc = new XmlDocument();
//加载索引文件
xmldoc.Load(Server.MapPath("contents.xml"));
string insstr;
//生成新闻索引
insstr = "" + TextBox2.Text + "main.aspx?name=" + TextBox1.Text + "";
XmlDocumentFragment docFrag = xmldoc.CreateDocumentFragment();
docFrag.InnerXml = insstr;
CurrNode = xmldoc.DocumentElement;
//插入新闻索引队列中
CurrNode.InsertAfter(docFrag, CurrNode.LastChild);
//保存索引文件
xmldoc.Save(Server.MapPath("contents.xml"));
//把TextBox5中的文件换成符合xml格式的内容
string xmlfile;
xmlfile = TextBox5.Text;
xmlfile = xmlfile.Replace("<", "+lt; ");
xmlfile = xmlfile.Replace(">", "+gt; ");
xmlfile = xmlfile.Replace("//", "+apos;");
xmlfile = xmlfile.Replace("\r\n", "");
//把数据写入新建的xml文件中去;
XmlDocument doc;
doc = new XmlDocument();
insstr = "";<BR> insstr += TextBox2.Text + "" + TextBox4.Text;
insstr += "
" + TextBox3.Text + "";
insstr += xmlfile + "
";
doc.LoadXml(insstr);
doc.Save(Server.MapPath(TextBox1.Text + ".xml"));
Response.Write("新闻发布成功!");
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
}
}
}
现在,一个简单的新闻发布系统已经建立完毕,你还可以编写更新程序,可以参照发布程序来写,有什么好的办法希望我们共享哦!




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.