protected void Page_Load(object sender, EventArgs e) { try { ciPage = Convert.ToInt32(Request.QueryString["page"].ToString()); } catch (Exception ex) { ciPage = 1; } if (Request.QueryString["order"] == "desc") { cbOrder = true; } else { cbOrder = false; } try { ArrayList laFiles = new ArrayList(); string lsError = String.Empty; int i = 0; int liStart = 0; int liEnd = 0; gbSerialize coSerialize = new gbSerialize(csPath + "\\App_Data"); string lsPath = Request.ApplicationPath; laFiles = coSerialize.GetFileNames(); Utility.GetStartAndEnd(ref liStart, ref liEnd, laFiles.Count, ciPage, cbOrder, Convert.ToInt16(ciMsgPerPage)); if (cbOrder) { for (i=liStart; i<liEnd; i++) { gbMessage loMessage = new gbMessage(); loMessage = (gbMessage)coSerialize.DeserializeMessage(laFiles[i].ToString(), ref lsError); MsgDisplay.Text += coSerialize.DisplayMessage(loMessage, lsPath, csPath); } } else { for (i=liStart; i> liEnd; i--) { gbMessage loMessage = new gbMessage(); loMessage = (gbMessage)coSerialize.DeserializeMessage(laFiles[i - 1].ToString(), ref lsError); MsgDisplay.Text += coSerialize.DisplayMessage(loMessage, lsPath, csPath); } } lblNavigation.Text = Utility.GenerateNavigation(laFiles.Count, ciPage, cbOrder, "List", Convert.ToInt16(ciMsgPerPage)); } catch (Exception ex) { Response.Write("<b>Error</b>: " + ex.Message.ToString()); } }
private void LoadMessages() { laFiles = new ArrayList(); lsError = String.Empty; i = 0; liStart = 0; liEnd = 0; coSerialize = new gbSerialize(csPath + "\\App_Data\\Guestbook"); lsPath = Request.ApplicationPath; laFiles = coSerialize.GetFileNames(); Utility.GetStartAndEnd(ref liStart, ref liEnd, laFiles.Count, ciPage, Convert.ToInt16(ciMsgPerPage)); StringBuilder messages = new StringBuilder(); for (i = liStart; i > liEnd; i--) { var loMessage = coSerialize.DeserializeMessage(laFiles[i - 1].ToString(), ref lsError); messages.Append(coSerialize.DisplayMessage(loMessage, lsPath, csPath)); } MsgDisplay.Text = messages.ToString(); }
protected void Page_Load(object sender, EventArgs e) { if (Convert.ToString(Session["AdminUsername"]) == csAdminUsername && Convert.ToString(Session["AdminPassword"]) == csAdminPassword) { // Login Successfull! AdminLoginControl.Visible = false; MsgDisplay.Visible = true; lblNavigation.Visible = true; // Check if Message Needs to be Deleted --------------------- if (Utility.IsNumeric(Request.QueryString["msg"])) { try { File.Delete(csPath + "\\App_Data\\" + Request.QueryString["msg"] + ".xml"); MsgDisplay.Text = "Message Removed!<br /><a href=\"Admin.aspx\">Click Here</a> to continue."; return; } catch (Exception ex) { MsgDisplay.Text = "Could not remove message!"; } } // Actual Display of Messages ------------------------------- try { ciPage = Convert.ToInt32(Request.QueryString["page"].ToString()); } catch (Exception ex) { ciPage = 1; } if (Request.QueryString["order"] == "desc") { cbOrder = true; } else { cbOrder = false; } try { ArrayList laFiles = new ArrayList(); string lsError = ""; int i = 0; int liStart = 0; int liEnd = 0; gbSerialize coSerialize = new gbSerialize(csPath + "\\App_Data"); string lsPath = Request.ApplicationPath; laFiles = coSerialize.GetFileNames(); Utility.GetStartAndEnd(ref liStart, ref liEnd, laFiles.Count, ciPage, cbOrder, Convert.ToInt16(ciMsgPerPage)); if (cbOrder == true) { for (i = liStart; i < liEnd; i++) { gbMessage loMessage = new gbMessage(); loMessage = coSerialize.DeserializeMessage(laFiles[i].ToString(), ref lsError); MsgDisplay.Text += "<a href=\"Admin.aspx?msg=" + loMessage.ID + "\">Delete Message</a>"; MsgDisplay.Text += coSerialize.DisplayMessage(loMessage, lsPath, csPath); } } else { for (i = liStart; i > (liEnd); i--) { gbMessage loMessage = new gbMessage(); loMessage = coSerialize.DeserializeMessage(laFiles[i - 1].ToString(), ref lsError); MsgDisplay.Text += "<a href=\"Admin.aspx?msg=" + loMessage.ID + "\">Delete Message</a>"; MsgDisplay.Text += coSerialize.DisplayMessage(loMessage, lsPath, csPath); } } lblNavigation.Text = Utility.GenerateNavigation(laFiles.Count, ciPage, cbOrder,"Admin", Convert.ToInt16(ciMsgPerPage)); } catch (XmlException ex) { Response.Write("<b>Error</b>: " + ex.Message.ToString()); } } else { // Login Failed! AdminLoginControl.Visible = true; MsgDisplay.Visible = false; lblNavigation.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { ciPage = GSDlib.Utils.NullableInt(Request.QueryString["page"]) ?? 1; var laFiles = new ArrayList(); string lsError = String.Empty; int i = 0; int liStart = 0; int liEnd = 0; var coSerialize = new gbSerialize(csPath + "\\App_Data\\Guestbook"); string lsPath = Request.ApplicationPath; laFiles = coSerialize.GetFileNames(); Utility.GetStartAndEnd(ref liStart, ref liEnd, laFiles.Count, ciPage, Convert.ToInt16(ciMsgPerPage)); StringBuilder messages = new StringBuilder(); for (i = liStart; i > liEnd; i--) { var loMessage = coSerialize.DeserializeMessage(laFiles[i - 1].ToString(), ref lsError); messages.Append(coSerialize.DisplayMessage(loMessage, lsPath, csPath)); } MsgDisplay.Text = messages.ToString(); lblNavigation.Text = GenerateNavigation(laFiles.Count, ciPage, "Gastenboek", Convert.ToInt16(ciMsgPerPage)); }