PageRenderTime 2ms CodeModel.GetById 21ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/widgets/RecentComments/edit.ascx.cs

#
C# | 58 lines | 31 code | 10 blank | 17 comment | 1 complexity | 7b24aa6d1eae74a531f052a4b952ecd2 MD5 | raw file
 1// --------------------------------------------------------------------------------------------------------------------
 2// <summary>
 3//   The edit.
 4// </summary>
 5// --------------------------------------------------------------------------------------------------------------------
 6
 7namespace Widgets.RecentComments
 8{
 9    using System;
10    using System.Web;
11
12    using App_Code.Controls;
13    using BlogEngine.Core;
14
15    /// <summary>
16    /// The edit.
17    /// </summary>
18    public partial class Edit : WidgetEditBase
19    {
20        #region Public Methods
21
22        /// <summary>
23        /// Saves this the basic widget settings such as the Title.
24        /// </summary>
25        public override void Save()
26        {
27            var settings = this.GetSettings();
28            settings["numberofcomments"] = this.txtNumberOfPosts.Text;
29            this.SaveSettings(settings);
30            Blog.CurrentInstance.Cache.Remove("widget_recentcomments");
31        }
32
33        #endregion
34
35        #region Methods
36
37        /// <summary>
38        /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event.
39        /// </summary>
40        /// <param name="e">
41        /// An <see cref="T:System.EventArgs"/> object that contains the event data.
42        /// </param>
43        protected override void OnPreRender(EventArgs e)
44        {
45            base.OnPreRender(e);
46
47            if (this.Page.IsPostBack)
48            {
49                return;
50            }
51
52            var settings = this.GetSettings();
53            this.txtNumberOfPosts.Text = settings.ContainsKey("numberofcomments") ? settings["numberofcomments"] : "10";
54        }
55
56        #endregion
57    }
58}