Skip to content

Instantly share code, notes, and snippets.

View sitefinitysteve's full-sized avatar
🏠
Working from home

Steve McNiven-Scott sitefinitysteve

🏠
Working from home
View GitHub Profile
@sitefinitysteve
sitefinitysteve / Sitefinity Rename Forms Database Table
Created June 4, 2012 13:51
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 / CollectionExtensions.cs
Last active June 10, 2020 01:45
SitefinitySteve Extension Collection, included in the RandomSiteControls
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Telerik.Sitefinity
{
public static class CollectionExtensions
{
/// <summary>
@sitefinitysteve
sitefinitysteve / Samples.aspx
Last active December 19, 2015 04:38
Sitefinity Template Layout Helpers. Use these in a RadListView to generate you dynamic layout wrappers around your content.
<!-- Regular Sample -->
<telerik:RadListView ID="dynamicContentListView" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
<LayoutTemplate>
<div class="sf_cols">
<asp:PlaceHolder ID="ItemsContainer" runat="server" />
</div>
</LayoutTemplate>
<ItemTemplate>
<div class='<%# Util.Out(Container) %>'>
<div class='<%# Util.In(Container) %>'>
@sitefinitysteve
sitefinitysteve / SitefinityLayoutSamples.html
Created July 1, 2013 05:15
Sitefinity Layout Control Samples
<!-- 2 col sample -->
<div class="sf_cols">
<div class="sf_colsOut sf_2cols_1_50">
<div class="sf_colsIn sf_2cols_1in_50">
</div>
</div>
<div class="sf_colsOut sf_2cols_2_50">
<div class="sf_colsIn sf_2cols_2in_50">
@sitefinitysteve
sitefinitysteve / SimpleImage
Created July 31, 2013 02:18
Replacement for the sitefinity image asset field control, allows you to set a microdata attribute as well (among other things)
using System;
using System.Linq;
using System.Web;
using Telerik.Sitefinity.Configuration;
using Telerik.Sitefinity.DynamicModules.Model;
using System.Web.UI;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.Model.ContentLinks;
using Telerik.Sitefinity.Modules.Libraries;
using Telerik.Sitefinity.SitefinityExceptions;
using System;
using System.Linq;
using Telerik.Sitefinity.Services;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
@sitefinitysteve
sitefinitysteve / RadDocumentPdfDownload.cs
Last active August 24, 2020 16:21
Sitefinity RadDocument PDF Export Sample
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();
<rule name="Default Document" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{REQUEST_URI}" pattern="^\/home$" />
<add input="{REQUEST_URI}" pattern="^\/default.aspx$" />
</conditions>
<action type="Redirect" url="/" appendQueryString="false" redirectType="Permanent" />
</rule>
<rule name="RedirectToWWW" enabled="true" stopProcessing="true">
<match url=".*" />
@sitefinitysteve
sitefinitysteve / gist:9d22b8ea8e0856e5f465
Created November 11, 2014 13:22
Application_Error to handle document passthrough
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 / Download.aspx
Created November 11, 2014 13:27
Download.aspx Document Download
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Download.aspx.cs" Inherits="SitefinityWebApp.Download" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
var max_time = 5;
var cinterval;