コード例 #1
0
        /// <summary>
        /// Speichert einen vom Administrator geänderten Eintrag.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void OnEditSave(object sender, System.EventArgs e)
        {
            // TODO: Aktuellen Eintrag speichern.
            string id = ((Portal.API.Controls.LinkButton)sender).CommandArgument;

            GuestbookData data = ReadData();

            GuestbookData.GuestbookRow row = (GuestbookData.GuestbookRow)data.Guestbook.Select("ID = '" + id + "'")[0];
            row.Name    = HttpUtility.HtmlEncode(m_FromTB.Text);
            row.Email   = HttpUtility.HtmlEncode(m_EmailTB.Text);
            row.Url     = HttpUtility.HtmlEncode(m_UrlTB.Text);
            row.Title   = HttpUtility.HtmlEncode(m_TitleTB.Text);
            row.Message = HttpUtility.HtmlEncode(m_MessageTB.Text).Replace("\n", "<br/>");
            row.Comment = HttpUtility.HtmlEncode(m_CommentTB.Text).Replace("\n", "<br/>");
            WriteData(data);

            // Die Darstellung wird auf "Benutzermodus" gesetzt.
            SetVisualMode(false);

            // Zurücksetzen der Eingabefelder.
            Clear();

            // Darstellen der Gästebuchdaten mit Hilfe des Repeaters.
            Bind();
        }
コード例 #2
0
        /// <summary>
        /// Fügt den Eintrag ins Gästebuch ein.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected void OnAdd(Object sender, EventArgs args)
        {
            try
            {
                // Prüfen, ob gültige Daten vorliegen. Falls nicht, speichern wir den eintrag nicht ab.
                m_MessageTB.Text = m_MessageTB.Text.Trim();
                if (m_MessageTB.Text == "")
                {
                    return;
                }
                m_FromTB.Text = m_FromTB.Text.Trim();
                if (m_FromTB.Text == "")
                {
                    return;
                }

                // Speichern des Eintrages.
                GuestbookData data             = ReadData();
                GuestbookData.GuestbookRow row = data.Guestbook.NewGuestbookRow();
                row.Created = DateTime.Now;
                row.Name    = HttpUtility.HtmlEncode(m_FromTB.Text);
                row.Email   = HttpUtility.HtmlEncode(m_EmailTB.Text);
                row.Url     = HttpUtility.HtmlEncode(m_UrlTB.Text.Trim());
                if ((((string)row.Url).Length > 0) && !((string)row.Url).StartsWith("http://"))
                {
                    row.Url = "http://" + (string)row.Url;
                }
                row.Title   = HttpUtility.HtmlEncode(m_TitleTB.Text);
                row.Message = HttpUtility.HtmlEncode(m_MessageTB.Text).Replace("\n", "<br/>");
                row.Id      = Guid.NewGuid();
                row.Comment = "";

                data.Guestbook.Rows.Add(row);
                WriteData(data);

                // Wenn gewünscht, senden wir hier ein Notifizierungsmail.
                if ((bool)m_ConfigData.Tables["Guestbook"].Rows[0]["SendNotification"])
                {
                    SendMail();
                }

                // Zurücksetzen der Eingabefelder.
                Clear();

                // Darstellen der Gästebuchdaten mit Hilfe des Repeaters.
                Bind();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
コード例 #3
0
        /// <summary>
        /// Bearbeiten des gewählten Eintrages.
        /// </summary>
        /// <param name="id"></param>
        private void OnEdit(Guid id)
        {
            // Setzen der ID als CommandArgument des Speicher-Buttons.
            m_EditSaveBtn.CommandArgument = id.ToString();

            GuestbookData data = ReadData();

            GuestbookData.GuestbookRow row = (GuestbookData.GuestbookRow)data.Guestbook.Select("ID = '" + id + "'")[0];
            m_FromTB.Text    = HttpUtility.HtmlDecode(row.Name);
            m_EmailTB.Text   = HttpUtility.HtmlDecode(row.Email);
            m_UrlTB.Text     = HttpUtility.HtmlDecode(row.Url);
            m_TitleTB.Text   = HttpUtility.HtmlDecode(row.Title);
            m_MessageTB.Text = HttpUtility.HtmlDecode(row.Message.Replace("<br/>", "\n"));
            if (!string.IsNullOrEmpty(row.Comment))
            {
                m_CommentTB.Text = HttpUtility.HtmlDecode(row.Comment.Replace("<br/>", "\n"));
            }

            // Die Darstellung wird auf "Editmodus" gesetzt.
            SetVisualMode(true);
        }