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.Collections.Specialized; public partial class StorePersonalization : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //DisplayServerVariables(); if (!IsPostBack) { TextBox1.Text = Profile.FirstName; TextBox2.Text = Profile.LastName; TextBox3.Text = Profile.EmailPrivate; TextBox4.Text = Profile.EmailWork; TextBox5.Text = Profile.AddressRow1; TextBox6.Text = Profile.AddressRow2; TextBox7.Text = Profile.PostCode; TextBox8.Text = Profile.PostAdress; TextBox9.Text = Profile.PhoneHome; TextBox10.Text = Profile.PhoneWork; TextBox11.Text = Profile.CellPhone; if (Profile.Member == true) { Radiobuttonlist1.Items[0].Selected = true; Radiobuttonlist1.Items[1].Selected = false; } else { Radiobuttonlist1.Items[0].Selected = false; Radiobuttonlist1.Items[1].Selected = true; } if (Profile.LastVisited.ToString() != "0001-01-01 00:00:00") Label1.Text = "Du (" + Profile.IPAddress + ") besökte sidan " + Profile.LastVisited.ToString(); else Label1.Text = "Välkommen! Detta är ditt första besök på den här sidan."; } } protected void Button1_Click(object sender, EventArgs e) { if (Page.User.Identity.IsAuthenticated) { Profile.FirstName = TextBox1.Text; Profile.LastName = TextBox2.Text; Profile.EmailPrivate = TextBox3.Text; Profile.EmailWork = TextBox4.Text; Profile.AddressRow1 = TextBox5.Text; Profile.AddressRow2 = TextBox6.Text; Profile.PostCode = TextBox7.Text; Profile.PostAdress = TextBox8.Text; Profile.PhoneHome = TextBox9.Text; Profile.PhoneWork = TextBox10.Text; Profile.CellPhone = TextBox11.Text; if (Radiobuttonlist1.SelectedItem.ToString() == "Yes") Profile.Member= true; else Profile.Member = false; Profile.LastVisited = DateTime.Now; Profile.IPAddress = Request.ServerVariables["REMOTE_ADDR"]; Label1.Text = "Sparad information:

" + "Förnamn: " + Profile.FirstName + "
Efternamn: " + Profile.LastName + "
Epost privat: " + Profile.EmailPrivate + "
Epost arbete: " + Profile.EmailWork + "
Adress rad 1:" + Profile.AddressRow1 + "
Adress rad 2:" + Profile.AddressRow2 + "
Postnummer:" + Profile.PostCode + "
Postadress:" + Profile.PostAdress + "
Telefonnr hem:" + Profile.PhoneHome + "
Telefonnr arb.:" + Profile.PhoneWork + "
Mobilnr:" + Profile.CellPhone + "
Medlem: " + Profile.Member + "
Senaste besök: " + Profile.LastVisited; } else { if (Radiobuttonlist1.SelectedItem.ToString() == "Yes") Profile.Member = true; else Profile.Member = false; Profile.IPAddress = Server.HtmlEncode(Request.ServerVariables["REMOTE_ADDR"]); Profile.LastVisited = DateTime.Now; Label1.Text = "För att få tillgång till interna dokument, måste du logga in!"; } } private void DisplayServerVariables() { int loop1, loop2; NameValueCollection coll; // Load ServerVariable collection into NameValueCollection object. coll = Request.ServerVariables; // Get names of all keys into a string array. String[] arr1 = coll.AllKeys; for (loop1 = 0; loop1 < arr1.Length; loop1++) { Response.Write("Key: " + arr1[loop1] + "
"); String[] arr2 = coll.GetValues(arr1[loop1]); for (loop2 = 0; loop2 < arr2.Length; loop2++) { Response.Write("Value " + loop2 + ": " + Server.HtmlEncode(arr2[loop2]) + "
"); } } } }