动态网站制作指南 [  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.NET实例
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.NET实例 ]的信息



本月文章推荐
.ASP.NET中实时图表的实现.
.ASP.Net+XML打造留言薄.
.ASP.NET实现用户在线检测的类源码.
.基于asp.net的webmenu的数据操作2.
.用asp.net画饼图(可用于各种投票.
..net 2.0(c#)下简单的FTP应用程序.
.用C#编写发手机中文短信息Window.
.做完一个小网站的一点经验总结(1.
.ASP.NET中动态修改web.config中的.
.保存美丽记忆 用ASP.NET创建网络.
.C#版的网站新闻发布系统.
.利用ASP.NET构建网上考试系统.
.ASP.NET结合存储过程写的通用搜索.
.ASP.NET中的状态管理.
.如何实现站点的RSS输出.
.检测是否还有黑客代码的asp.net函.
.根据IP获取当地天气预报的实现.
.用ASP.Net写一个发送ICQ信息的程.
.DotNet语音技术实现.
.使用net classes访问其他网站内容.

如何建立自己的新闻发布系统?

发表日期:2006-10-14 |


下面是一个建立新闻发布系统的程序,不用和数据库打交道哦
步骤:
(1).在vs2005中新建网站,新建三个aspx网页,分别命名:title.aspx,news.aspx,main.aspx其中title.aspx用来设置标题,可以自己设计,写几个字也行,news.aspx用来显示新闻标题,main.aspx用来显示新闻内容。
(2).新建htm页,用来设计框架。代码如下:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>无标题页</title>
</head>
<frameset border="0" bordercolor="#6699cc" framespacing="3" id="fsTop"  rows="85,*">
  <frame  frameborder="no" marginheight="0"  marginwidth="0" name="title" noresize scrolling="no" src="title.aspx" >
  <frameset border="0" frameborder="1" framespacing="3"   cols="110,*">
    <frame  frameborder="0" marginheight="0" marginwidth="0" name="dir" src="news.aspx"  style="BORDER-RIGHT: #99ccff 1px solid; BORDER-TOP: #003366 1px solid"  scrolling="auto" >
    <frame bordercolor="#6699cc" frameborder="0" name="main" scrolling="yes" src="main.aspx?name=hello" style="BORDER-LEFT: #99ccff 2px groove; BORDER-TOP: #003366 1px solid">
  </frameset>
</frameset>
</html>(3).现在你的程序还没有内容,新建xml文件,命名contents.xml,用来显示新闻标题,代码如下:
<?xml version="1.0" encoding="GB2312"?>
<topiclist type="Dreamsite News">
  <topic>
    <title>欢迎进入千里之外的新闻网!</title>
    <href>main.aspx?name=hello</href>
  </topic>
  <topic>
    <title>测试新闻</title>
    <href>main.aspx?name=test</href>
  </topic>
  <topic>
    <title> 第一条新闻</title>
    <href>main.aspx?name=first</href>
  </topic>
  <topic>
    <title> 第二条新闻</title>
    <href>main.aspx?name=dddd</href>
</topiclist>注意我们的每条新闻内容都是一个xml文件,现在你知道该做什么了吧,新建hello.xml;test.xml;first.xml;dddd.xml文件,在这里给出一个例子,代码如下:
<?xml version="1.0" encoding="GB2312"?>
<document>
  <title>今日新闻</title>
  <abstract>头版新闻</abstract>
  <author>千里之外</author>
  <content>&lt;paragraph&gt;大家好&lt;/paragraph&gt;</content>
</document>现在你就可以看到效果了,下面我们看一下发布新闻的代码,也很简单,新建manage.aspx页面,前台代码:
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <p>千里之外个人新闻发布系统
            </p>
            文件名:
            <asp:textbox id="TextBox1" runat="Server" />
            <Asp:RequiredFieldValidator id="valid1" ControlToValidate="Textbox1" runat="Server">(必要栏)
</Asp:RequiredFieldValidator><p>
                文章名称:
                <asp:textbox id="TextBox2" runat="server" />
                <Asp:RequiredFieldValidator id="valid2" ControlToValidate="Textbox2" runat="Server">(必要栏)
</Asp:RequiredFieldValidator>
            <p>
                作者:
                <asp:textbox id="TextBox3" runat="server" />
                <Asp:RequiredFieldValidator id="valid3" ControlToValidate="Textbox3" runat="Server">(必要栏)
</Asp:RequiredFieldValidator>
            <p>
            摘要:<p>
                <asp:textbox id="TextBox4" textmode="MultiLine" width="70%" runat="server" />
            <p>
            内容:<p>
                <asp:textbox id="TextBox5" textmode="MultiLine" rows="6" width="70%" runat="server" />
            <p>
                <asp:Button id="submit" text="提交"  runat="server" />
    </div>
    </form>
</body>后台代码如下:
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 = "<topic><title>" + TextBox2.Text + "</title><href>main.aspx?name=" + TextBox1.Text + "</href></topic>";
            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", "</paragraph><paragraph>");
            //把数据写入新建的xml文件中去;
            XmlDocument doc;
            doc = new XmlDocument();
            insstr = "<?xml version='1.0' encoding='GB2312'?><document><title>";
            insstr += TextBox2.Text + "</title><abstract>" + TextBox4.Text;
            insstr += "</abstract><author>" + TextBox3.Text + "</author><content><paragraph>";
            insstr += xmlfile + "</paragraph></content></document>";
            doc.LoadXml(insstr);
            doc.Save(Server.MapPath(TextBox1.Text + ".xml"));
            Response.Write("新闻发布成功!");
            TextBox1.Text = "";
            TextBox2.Text = "";
            TextBox3.Text = "";
            TextBox4.Text = "";
            TextBox5.Text = "";
        }
    }
}
现在,一个简单的新闻发布系统已经建立完毕,你还可以编写更新程序,可以参照发布程序来写,有什么好的办法希望我们共享哦!
http://www.cnblogs.com/support/archive/2006/10/13/528544.html
上一篇:自己写的一个图形验证码页面(Asp.Net2.0通过) 人气:19520
下一篇:支付宝接口(刚完成,应该是目前最好的了) 人气:18653
浏览全部ASP.NET 2.0的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-7-23 Menalto Gallery v2.3 Rc1 多国语
2008-7-23 深度学习网址导航系统 v2.6.1
2008-7-23 因特达crm2008客户关系管理系统
2008-7-23 60度 CMS v1.0 Build 080723
2008-7-23 幻影动漫网视频系统(Ppdong) v1.
2008-7-23 好易祝福墙 2008
2008-7-23 APJE私服发布系统 v2.0 PHP版
2008-7-23 毕业论文在线指导系统源码
2008-7-23 Jacky法律在线网站源码
2008-7-19 UltraEdit 简体中文增强版 14.10
2008-7-19 CentOS 5.2 i386 LiveCD
2008-7-19 Snapture多功能相机 v1.4
2008-7-19 iAcces中文输入法 v1.0Build016
2008-7-19 Cookbook烹饪秘籍 v2.5
2008-7-19 苹果专用DVD转换工具 v1.1.59汉化
2008-7-19 Modem修复软件ZiPhone修改版04.0
2008-7-19 AgileMessenger即时通讯工具美化
2008-7-19 Sketches画图软件 v0.7b6破解版


  发表评论
姓 名: 验证码:
内 容:
[ 汉字翻译拼音 ] [ 广告代码 ] [ 符号对照表 ] [ 进制转换 ] [ 经典小工具 ] [ 个税计算 ] [ 汉字简繁转换 ] [ 普通单位换算 ] [ 公制单位换算 ]
[ 生辰老黄历 ] [ 国内电话区号 ] [ 国家代码与域名缩写 ] [ 文字加密解密 ] [ 健康查询 ] [ 万年历 ] [ 手机号码查询 ] [ ip搜索 ] [ Google PR查询 ]
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号
ホームページ制作 不動産検索システム 求人情報
防水工事·改修工事 フットサル大会 探偵