Created
September 8, 2009 13:51
-
-
Save jpoehls/182923 to your computer and use it in GitHub Desktop.
TokenReplacementMasterPage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
using System.IO; | |
using System.Web.UI; | |
namespace Boo | |
{ | |
public class TokenReplacementMasterPage : System.Web.UI.MasterPage | |
{ | |
protected override void Render(HtmlTextWriter writer) | |
{ | |
StringBuilder pageSource = new StringBuilder(); | |
StringWriter sw = new StringWriter(pageSource); | |
HtmlTextWriter htmlWriter = new HtmlTextWriter(sw); | |
base.Render(htmlWriter); | |
RunGlobalReplacements(pageSource); | |
writer.Write(pageSource.ToString()); | |
} | |
private static void RunGlobalReplacements(StringBuilder pageSource) | |
{ | |
pageSource.Replace("{WebsiteEmailAddress}", AppSettings.EmailAddress); | |
pageSource.Replace("{DatabaseName}", GetSelectedDatabaseName()); | |
pageSource.Replace("{SupportPhone}", AppSettings.PhoneNumber); | |
} | |
private static string GetSelectedDatabaseName() | |
{ | |
if (CState.Database != null) | |
{ | |
return CState.Database.FriendlyName; | |
} | |
else | |
{ | |
return string.Empty; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment