Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Steve McNiven-Scott sitefinitysteve

Block or report user

Report or block sitefinitysteve

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sitefinitysteve
sitefinitysteve / RadDocumentPdfDownload
Last active Aug 29, 2015
Sitefinity RadDocument PDF Export Sample
View RadDocumentPdfDownload
protected void OnDownloadPDF_Click(object sender, EventArgs e) {
string output = "";
byte[] buffer = new byte[0];
string filename = "file"
string html = Util.GetHtmlToExport(); //However you want...this is a fake stub
var thread = new Thread(() =>
{
Telerik.Windows.Documents.FormatProviders.Pdf.PdfFormatProvider provider = new Telerik.Windows.Documents.FormatProviders.Pdf.PdfFormatProvider();
@sitefinitysteve
sitefinitysteve / gist:9d22b8ea8e0856e5f465
Created Nov 11, 2014
Application_Error to handle document passthrough
View gist:9d22b8ea8e0856e5f465
protected void Application_Error()
{
//Sitefinity Logger should send to raygun now
var exception = Server.GetLastError();
//Send document requests over to login
if(exception.Message.Contains("You are not authorized to 'View document'") || exception.Message.Contains("You are not authorized to 'View image'")){
if (!ClaimsManager.GetCurrentIdentity().IsAuthenticated)
{
//If user is anonymous, send them to the login
@sitefinitysteve
sitefinitysteve / ServiceStackService
Created Nov 21, 2014
Sitefinity JustCode ServiceStack File Template
View ServiceStackService
using System;
using System.Collections.Generic;
using System.Linq;
using Telerik.Sitefinity;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.DynamicModules;
using Telerik.Sitefinity.Data.Linq.Dynamic;
using Telerik.Sitefinity.Services.Search;
using Telerik.Sitefinity.Utilities.TypeConverters;
using ServiceStack.Text;
@sitefinitysteve
sitefinitysteve / gist:6ec00100ec457ab1289d
Created Nov 25, 2014
DataIntelligenceScriptControl Const String
View gist:6ec00100ec457ab1289d
private const string ExecuteDataIntelligenceSubmitScriptFormat = "(function() {{\r\n var jqueryXhrModified = false;\r\n var detectjs = false;\r\n var executeDataIntelligenceScript = function() {{\r\n var source;\r\n if (!window.JSON) {{\r\n source = '{0}';\r\n }} else if (!window.jQuery) {{\r\n source = '{1}';\r\n }} else if (!jqueryXhrModified) {{\r\n source = '{2}';\r\n jqueryXhrModified = true;\r\n }} else if (!detectjs) {{\r\n source = '{3}';\r\n detectjs = true;\r\n }} else if (!window.DataIntelligenceSubmitScript) {{\r\n source = '{4}';\r\n }} else if (!window.sfDataIntell) {{\r\n source = '{5}';\r\n }} else {{\r\n return DataIntelligenceSubmitScript.load({6});\r\n }}\r\n var script = document.createElement('script');\r\n script.type = 'text/javascript';\r\n var callback = function() {{\r\n if (!this.rea
@sitefinitysteve
sitefinitysteve / SitefinityToolsFile.xml
Created Jan 6, 2015
Best Sitefinity RadEditor ToolsFile, use at /Sitefinity/Administration/Settings/Basic/TextEditor/
View SitefinityToolsFile.xml
<?xml version="1.0" encoding="UTF-8"?>
<root>
<modules>
<module name="RadEditorStatistics" dockingZone="Bottom" visible="false" />
<module name="RadEditorDomInspector" visible="true" />
<module name="RadEditorNodeInspector" visible="false" />
<module name="RadEditorHtmlInspector" visible="false" />
</modules>
<tools name="MainToolbar">
<tool name="ToggleAdvancedToolbars" />
@sitefinitysteve
sitefinitysteve / UploadFile.cs
Created Apr 8, 2015
Sitefinity Helper to upload a file
View UploadFile.cs
public static Document UploadFile(string fileTitle, Stream fileStream, string fileExtension, DocumentLibrary album, Guid folderId, List<Guid> categories, List<Guid> tags, string provider = "")
{
if (album != null)
{
LibrariesManager manager = LibrariesManager.GetManager(provider);
manager.Provider.SuppressSecurityChecks = true;
string urlname = Util.UrlNameFilter(fileTitle);
Document document = null;
//Check for document
@sitefinitysteve
sitefinitysteve / RunWithUserRegion.cs
Created Jun 9, 2015
Responsible for running set of operations with specific user
View RunWithUserRegion.cs
using System;
using System.Linq;
using System.Security.Principal;
using System.Threading;
using System.Web;
using Telerik.Sitefinity.Security;
using Telerik.Sitefinity.Security.Model;
using Telerik.Sitefinity.Services;
namespace Telerik.Sitefinity.TestUtilities.CommonOperations.Permissions.Api
@sitefinitysteve
sitefinitysteve / SimpleViewControlReference
Created Aug 24, 2015
JustCode template to reference a control in a Sitefinity .ascx simpleview template. I usually bind it to "sfv".
View SimpleViewControlReference
protected virtual $2$ $1$
{
get{
return this.Container.GetControl<$2$>("$1$", true);
}
}
View Sitefinity Rename Forms Database Table
-- the old name of the form
declare @oldName nvarchar(30) = 'sf_table_name';
-- the new name of the form
declare @newName nvarchar(30) = 'sf_table_name';
-- rename the table with form entries
exec sp_rename @oldName, @newName;
-- change the form name in the forms description
update [sf_form_description]
@sitefinitysteve
sitefinitysteve / DetectIndexRenderingMVCFeather.cshtml
Created Oct 14, 2015
Detect when your view is being indexed
View DetectIndexRenderingMVCFeather.cshtml
@using Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers;
@if (ViewContext.Controller.GetIndexRenderMode() == Telerik.Sitefinity.Web.UI.IndexRenderModes.Normal)
{
<div>FROM LAYOUT</div>
}
You can’t perform that action at this time.