Last active
August 11, 2018 23:06
-
-
Save sotirisf/477c41be2e8dca3b3755c4c53a9f62f4 to your computer and use it in GitHub Desktop.
Code behind for Umbraco dynamically- generated Javascript for hiding back-end properties
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.Configuration; | |
| using System.Web; | |
| namespace MyNamespace | |
| { | |
| public class HidePropertiesJsOutput : IHttpHandler | |
| { | |
| public void ProcessRequest(HttpContext context) | |
| { | |
| context.Response.ContentType = "text/javascript"; | |
| string fieldsToHide = ConfigurationManager.AppSettings.Get("HideBackEndFields"); | |
| if (!string.IsNullOrEmpty(fieldsToHide)) | |
| { | |
| foreach (string field in fieldsToHide.Split(',')) | |
| { | |
| context.Response.Write("$(document).arrive(\"div[data-element='property-" + field + "']\", function () { $(this).hide(); });\r\n"); | |
| } | |
| } | |
| } | |
| public bool IsReusable | |
| { | |
| get | |
| { | |
| return false; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment