How to build your own press release system?

Source: Internet
Author: User
Tags abstract insert
Here's a program to build a news release system that doesn't have to deal with databases.
Steps:
(1). Create a new Web site in vs2005 and create a new three ASPX Web page named: title.aspx,news.aspx, Main.aspx which title.aspx used to set the title, you can design, write a few words also line, news.aspx used to display news headlines, main.aspx used to display news content.
(2). Create a new HTM page to design the framework. The code is as follows:
<title> Untitled Page </title>
<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>
<?xml version= "1.0" encoding= "GB2312"?>
<topiclist type= "Dreamsite News" >
<topic>
<title> Welcome to the thousands of miles away from the news network!</title>
</topic>
<topic>
<title> Test News </title>
</topic>
<topic>
<title> First News </title>
</topic>
<topic>
<title> Second News </title>
</topiclist> Note that each of our news stories is an XML file, now you know what to do, create a new Hello.xml;test.xml;first.xml;dddd.xml file, give an example here, the code is as follows:
<?xml version= "1.0" encoding= "GB2312"?>
<document>
<title> News Today </title>
<abstract> Front page News </abstract>
<author> thousands of miles away </author>
<content><paragraph> Everybody good </paragraph></content>
</document> Now you can see the effect of the following, we look at the release of the news code, but also very simple, new manage.aspx page, foreground code:
<body>
<form id= "Form1" runat= "Server" >
<div>
<p> Personal Press release system thousands of miles away
</p>
Filename:
<asp:textbox id= "TextBox1" runat= "Server"/>
<asp:requiredfieldvalidator id= "Valid1" controltovalidate= "Textbox1" runat= "Server" > (Required column)
</Asp:RequiredFieldValidator><p>
Article name:
<asp:textbox id= "TextBox2" runat= "Server"/>
<asp:requiredfieldvalidator id= "Valid2" controltovalidate= "Textbox2" runat= "Server" > (Required column)
</Asp:RequiredFieldValidator>
<p>
Author:
<asp:textbox id= "TextBox3" runat= "Server"/>
<asp:requiredfieldvalidator id= "Valid3" controltovalidate= "Textbox3" runat= "Server" > (Required column)
</Asp:RequiredFieldValidator>
<p>
Summary:<p>
<asp:textbox id= "TextBox4" textmode= "MultiLine" width= "70%" runat= "Server"/>
<p>
Content:<p>
<asp:textbox id= "TextBox5" textmode= "MultiLine" rows= "6" width= "70%" runat= "Server"/>
<p>
<asp:button id= "Submit" text= "submitted" runat= "Server"/>
</div>
</form>
</body> background code is as follows:
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)
{
To determine whether a file exists
if (File.exists (Server.MapPath (TextBox1.Text + ". xml"))
Response.Write ("FileName already exists, please select filename!");
Else
{
First insert the data into the news list
XmlNode Currnode;
XmlDocument xmldoc = new XmlDocument ();
Load index File
XmlDoc. Load (Server.MapPath ("Contents.xml"));
String Insstr;
Generate a News index
Insstr = "<topic><title>" + TextBox2.Text + "</title>XmlDocumentFragment Docfrag = xmldoc. Createdocumentfragment ();
Docfrag.innerxml = Insstr;
Currnode = xmldoc. DocumentElement;
Insert the News index queue
Currnode.insertafter (Docfrag, currnode.lastchild);
Save index file
XmlDoc. Save (Server.MapPath ("Contents.xml"));
Replace files in TEXTBOX5 with XML-formatted content
String xmlfile;
XMLFile = Textbox5.text;
XMLFile = xmlfile. Replace ("<", "+LT;");
XMLFile = xmlfile. Replace (">", "+GT;");
XMLFile = xmlfile. Replace ("//", "+apos;");
XMLFile = xmlfile. Replace ("\ r \ n", "</paragraph><paragraph>");
Write the data to the new XML file;
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 ("Press release successful!");
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
Textbox4.text = "";
Textbox5.text = "";
}
}
}
Now, a simple news release system has been established, you can also write updates, you can refer to the release process to write, what good way to hope we share Oh!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.