Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5.  
  6.  
  7. public class BasePage : System.Web.UI.Page {
  8.  
  9. public BasePage() {
  10. this.PreRender += Page_PreRender;
  11. }
  12.  
  13. protected override void OnPreInit(EventArgs e) {
  14. if(Request.Cookies["Page"] != null) {
  15. if (Request.Cookies["Page"].Value != null) {
  16. Page.Theme = Request.Cookies["Page"].Value;
  17. System.Diagnostics.Debug.WriteLine("Theme is: " + Request.Cookies["Page"].Value);
  18. }
  19. }
  20. else {
  21. Page.Theme = "Monochrome";
  22. }
  23.  
  24. base.OnPreInit(e);
  25. }
  26.  
  27. private void Page_PreRender(Object sender, EventArgs s) {
  28.  
  29. if(String.IsNullOrEmpty(this.Title) || this.Title.Equals("Untitled Page", StringComparison.CurrentCultureIgnoreCase))
  30. throw new Exception("Page title cannot be \"Untitled Page\" or an empty string...");
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement