3 votes

Renderscript

Add script aliases and paths to some cshmlts you like to be able to call in the "renderscript" template:

  aliases.Add("demo","~/macroscripts/demo.cshtml");   
 
... which it makes it calleable with www.mysite.com/renderscript?a=demo

For easy adding Ajax with the help of Razor scripts.

You can for example make a script that returns json:
@{
  var x = new {foo="whatever"};
  Json.Write (x, Response.Output);
  }

And you can make a script that handles postdata, for example:

@{
  var returnValue="";
  if (IsPost)
  {
     name = Request["name"];
     // do something useful...
     returnValue = "Thank you " + name + "!";
  }
  @returnValue
}

 

// The source for this is simply a template with the following content:

<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
 
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server"><umbraco:macro runat="server" language="razor">
@{

  var aliases = new Dictionary<string, string>();
     
  // add your script aliases here
  aliases.Add("demo","~/macroscripts/demo.cshtml");   
 
  // makes them calleable with www.mysite.com/renderscript?a=demo
 
  var alias = Request["a"];

  if (alias != null)
  {
    if (aliases.ContainsKey(alias))
    {
      @RenderPage(aliases[alias])
    }   
  }
}
</umbraco:macro></asp:Content>

Archived files

Documentation

Source code

Package owner

Jonas Eriksson

Jonas Eriksson

Jonas has 1825 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
8.2.x (untested)
8.1.x (untested)
8.0.x (untested)
7.15.x (untested)
7.14.x (untested)
7.13.x (untested)
7.12.x (untested)
7.11.x (untested)
7.10.x (untested)
7.9.x (untested)
7.8.x (untested)
7.7.x (untested)
7.6.x (untested)
7.5.x (untested)
7.4.x (untested)
7.3.x (untested)
7.2.x (untested)
7.1.x (untested)
7.0.x (untested)
6.1.x (untested)
6.0.x (untested)

You must login before you can report on package compatibility.

Package Information

  • Package owner: Jonas Eriksson
  • Created: 14/04/2011
  • Current version 1.0
  • License MIT
  • Downloads: 599