Hello boys and girls, the problem is (i guess) quite simple, when i push the button on my aspx page and write to the XML file the page disappears.
DEFAULT.ASPX.CS
protected void Button1_Click1(object sender, EventArgs e)
{
string email = "member69@hotmail.com";
string name = "joe doe";
string country = "helvetia";
string comments = "funkis??";
string datetime = "2minutestomidnight";
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.NewLineOnAttributes = true;
//Response.ContentType = "text/xml";
string strCurrentPath = "C:\\text,tutorials\\projektCsharp\\App_Data\\guest.xml";
using (XmlTextWriter writer = new XmlTextWriter(strCurrentPath, null))
{
writer.Formatting = Formatting.Indented;
writer.WriteStartDocument();
writer.WriteStartElement("Guests");
writer.WriteStartElement("Guest");
writer.WriteStartElement("Name");
writer.WriteValue(name);
writer.WriteEndElement();
writer.WriteStartElement("Country");
writer.WriteValue(country);
writer.WriteEndElement();
//writer.WriteEndAttribute();
// writer.WriteStartAttribute("Country");
// writer.WriteValue(country);
// writer.WriteEndAttribute();
// writer.WriteStartAttribute("Email");
// writer.WriteValue(email);
// writer.WriteEndAttribute();
// writer.WriteStartAttribute("Comments");
// writer.WriteValue(comments);
// writer.WriteEndAttribute();
// writer.WriteStartAttribute("DateTime");
// writer.WriteValue(datetime);
// writer.WriteEndAttribute();
writer.WriteEndElement();
writer.WriteEndElement();
// writer.WriteEndDocument();
//writer.WriteStartDocument();
////Write comments
//writer.WriteComment("Commentss: XmlWriter Test Program");
//writer.WriteProcessingInstruction("Instruction", "Person Record");
//// Add elements to the file
//writer.WriteStartElement("p", "person", "urn:person");
//writer.WriteStartElement("LastName", "");
//writer.WriteString("Chand");
//writer.WriteEndElement();
//writer.WriteStartElement("FirstName", "");
//writer.WriteString("Mahesh");
//writer.WriteEndElement();
//writer.WriteElementInt16("age", "", 25);
// Ends the document
writer.WriteEndDocument();
writer.Flush();
writer.Close();
Response.End();
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:panel id="TestPanel" runat="server" Height="171px" Width="398px">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="Button" />
</div>
<div>
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click1" Text="Button" />
</div>
</asp:panel>
</form>
</body>
</html>