using System;
using System.Data;
using System.Configuration;
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.Xml;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = "Gości online: " + Application.Get("uzytkownicyOnline").ToString() +" Liczba wszystkich odwiedzin: "+Application.Get("uzytkownicyTotal").ToString();
    }
    private void DodajWpisXML(XmlDocument dokument, XmlElement element, string tag, string wartosc)
    {
        XmlElement nowaGalaz = dokument.CreateElement(tag);
        XmlText tekst = dokument.CreateTextNode(wartosc);
        element.AppendChild(nowaGalaz);
        nowaGalaz.AppendChild(tekst);
    }
    protected void Button1_Click1(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            
                XmlDocument ksiega = new XmlDocument();
                ksiega.Load(Server.MapPath("ksiega.xml"));
                XmlElement nowyWpis;
                nowyWpis = ksiega.CreateElement("gosc");
                ksiega.DocumentElement.PrependChild(nowyWpis);
                DodajWpisXML(ksiega, nowyWpis, "nazwa", TextBox1.Text);
                DodajWpisXML(ksiega, nowyWpis, "e-mail", TextBox2.Text);
                DodajWpisXML(ksiega, nowyWpis, "komentarz", TextBox3.Text);
                ksiega.Save(Server.MapPath("ksiega.xml"));
                Response.Redirect("view.aspx");
            
        }
     

    }
}
