|
using System;
using System.Drawing;
using System.Xml;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Fireball.Web.Controls
{
public class RemovePost:WebControl
{
public RemovePost()
{
//NOP
}
protected override void Render(HtmlTextWriter writer)
{
if(Page.Session["login"] == null)
{
Page.Response.Redirect("login.aspx");
}
string id = Page.Request.QueryString["id"];
writer.Write("<table border='0' cellpadding='0' cellspacing='1' width='100%' class=\"news_table\">");
writer.Write("<td class='news_title'>");
writer.Write("Post Removal");
writer.Write("</td></tr>");
writer.Write("<tr><td class='addpost_content'>");
if(id != null && (id != string.Empty))
{
int pos = int.Parse(id);
XmlDocument xdoc = new XmlDocument();
xdoc.Load("./data/posts.xml");
XmlNodeList xlist = xdoc.SelectNodes("posts/article");
XmlNode xremove = xlist[pos];
xdoc.SelectSingleNode("posts").RemoveChild(xremove);
xdoc.Save("./data/posts.xml");
writer.Write("<p>Post removed succefully</p>");
writer.Write("<a href='manager.aspx'>Return to Manager</a>");
}
else
{
writer.Write("<p align='center'>Post not removed invalid id</p>");
writer.Write("<a href='manager.aspx'>Return to Manager</a>");
}
writer.Write("</td></tr>");
writer.Write("</table>");
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.