PageRenderTime 36ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
C# | 63 lines | 36 code | 12 blank | 15 comment | 2 complexity | 832834b96ec4f0bdf204cd08b06bff7b MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. // --------------------------------------------------------------------------------------------------------------------
  2. // <summary>
  3. // The widgets_ recent posts_edit.
  4. // </summary>
  5. // --------------------------------------------------------------------------------------------------------------------
  6. namespace Widgets.RecentPosts
  7. {
  8. using System;
  9. using System.Web;
  10. using App_Code.Controls;
  11. using BlogEngine.Core;
  12. /// <summary>
  13. /// The widgets_ recent posts_edit.
  14. /// </summary>
  15. public partial class Edit : WidgetEditBase
  16. {
  17. #region Public Methods
  18. /// <summary>
  19. /// Saves this the basic widget settings such as the Title.
  20. /// </summary>
  21. public override void Save()
  22. {
  23. var settings = this.GetSettings();
  24. settings["numberofposts"] = this.txtNumberOfPosts.Text;
  25. settings["showcomments"] = this.cbShowComments.Checked.ToString();
  26. settings["showrating"] = this.cbShowRating.Checked.ToString();
  27. this.SaveSettings(settings);
  28. Blog.CurrentInstance.Cache.Remove("widget_recentposts");
  29. }
  30. #endregion
  31. #region Methods
  32. /// <summary>
  33. /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event.
  34. /// </summary>
  35. /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
  36. protected override void OnPreRender(EventArgs e)
  37. {
  38. base.OnPreRender(e);
  39. if (this.Page.IsPostBack)
  40. {
  41. return;
  42. }
  43. var settings = this.GetSettings();
  44. this.txtNumberOfPosts.Text = settings.ContainsKey("numberofposts") ? settings["numberofposts"] : "10";
  45. this.cbShowComments.Checked = !settings.ContainsKey("showcomments") ||
  46. settings["showcomments"].Equals("true", StringComparison.OrdinalIgnoreCase);
  47. this.cbShowRating.Checked = !settings.ContainsKey("showrating") || settings["showrating"].Equals("true", StringComparison.OrdinalIgnoreCase);
  48. }
  49. #endregion
  50. }
  51. }