Last active
December 9, 2016 16:56
-
-
Save mguster/eb60843b8372ebac805eacdef5b18713 to your computer and use it in GitHub Desktop.
This file contains 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
<%@ Page Language="C#" AutoEventWireup="true" %> | |
<%@ Import Namespace="Sitecore.Sites" %> | |
<%@ Import Namespace="System.Globalization" %> | |
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head runat="server"> | |
<title>Sitecore Basic Admin Page</title> | |
<link rel="shortcut icon" href="/sitecore/images/favicon.ico" /> | |
<link rel="Stylesheet" type="text/css" href="/sitecore/shell/themes/standard/default/WebFramework.css" /> | |
<script type="text/javascript" src="/sitecore/shell/controls/lib/jQuery/jquery.js"></script> | |
<script type="text/javascript" src="/sitecore/shell/controls/lib/jQuery/jquery.watermark.js"></script> | |
<script type="text/javascript" src="/sitecore/shell/controls/webframework/webframework.js"></script> | |
<style> | |
.buttons{ | |
margin:1em 0; | |
} | |
.output-green { | |
color: green; | |
} | |
h1 { | |
margin-top: 20px; | |
} | |
h3 { | |
margin-top: 10px; | |
color: #0033BC; | |
font-weight: normal; | |
} | |
hr { | |
margin-top: 30px; | |
margin-bottom: 10px; | |
} | |
</style> | |
</head> | |
<body> | |
<form id="ScBasicAdminPageForm" class="wf-container" runat="server"> | |
<div class="wf-content"> | |
<h1>Sitecore Basic Admin Page</h1> | |
<h3>My Button</h3> | |
<p> | |
What's the button for? | |
</p> | |
<div class="buttons"> | |
<asp:Button ID="MyButton" runat="server" Text="Click Me!" OnClick="MyButtonClick" /> | |
</div> | |
<p class="output-green"> | |
<asp:Literal ID="OutputLiteral" runat="server" /> | |
</p> | |
<hr/> | |
</div> | |
<script runat="server"> | |
/// <summary> | |
/// Page Load event handler. | |
/// </summary> | |
protected override void OnLoad(EventArgs e) | |
{ | |
base.OnLoad(e); | |
CheckSecurityPermission("/sitecore/admin/ScBasicAdminPage.aspx{0}"); | |
InitControls(); | |
} | |
/// <summary> | |
/// Checks if the current user has the appropriate permissions to access the admin page. If not user is redirected to the login page. | |
/// </summary> | |
/// <param name="adminPagePath">The admin page path to which the user gets redirected after successful login.</param> | |
protected void CheckSecurityPermission(string adminPagePath) | |
{ | |
if (Sitecore.Context.User.IsAdministrator) | |
{ | |
return; | |
} | |
SiteContext site = Sitecore.Context.Site; | |
string url = (site != null) ? site.LoginPage : string.Empty; | |
string pageUrl = string.Format(CultureInfo.InvariantCulture, adminPagePath, string.IsNullOrEmpty(Request.QueryString.ToString()) ? string.Empty : "?" + Request.QueryString); | |
url += "?returnUrl=" + Server.UrlEncode(pageUrl); | |
if (url.Length > 0) | |
{ | |
Response.Redirect(url, true); | |
} | |
} | |
/// <summary> | |
/// Inizialises the asp controls | |
/// </summary> | |
private void InitControls() | |
{ | |
OutputLiteral.Text = string.Empty; | |
} | |
/// <summary> | |
/// Gets executed by the MyButton OnClick event | |
/// </summary> | |
protected void MyButtonClick(object sender, EventArgs e) | |
{ | |
OutputLiteral.Text = "Nothing!"; | |
} | |
</script> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Basic Sitecore Admin Page in the Sitecore Look & Feel