We hear it’s a good thing to separate view code from logic, and also to separate code into controller, model and view files. What does that actually mean? And why is that a good thing? Also does this mean we need to create model and controller class files for all our Umbraco Razor scripts? Consider […]
Read moreNice and simple Razor templates with the help of RenderPage and some dynamic sugar
Besides saving global helpers in App_Code we have the option to use RenderPage (or Html.Partial) in Razor to reuse code globally. Both ways helps in making the HTML code DRY and well structured. But an important difference is a RenderPage file can be wherever we want, and changes are fluent (no app restarts). We do […]
Read moreFun stuff : node.js in an Umbraco site
Did you ever want to run node.js within your umbraco site, and edit the server side javascript from within your Umbraco backend? Not? Well, it’s still a fun thing to do, don’t you think? Update 1: I actually think nodejs makes some sense within Umbraco. Why? Well, for example it makes it possible for js-peeps […]
Read moreA require module pattern in Asp.Net Razor
Did you ever need to load modules dynamically in Razor? Do you like to write function libraries in pure Razor, and be able to use them from other files without placing that function libraries in App_Code, and without forcing the App to restart? Not? Oh, well, anyways – as a friday evening experiment I hacked […]
Read moreSimple client side routes and content loading in Umbraco
Do you like your users to be able to load subcontent on a page dynamically and support client side url’s (which in turn enables browser history, url-copy&pasting and bookmarks)? In this post I will show how you can do it in a very flexible way with the help of Backbone.js and a minimum of code. […]
Read moreLive notifications on your Umbraco site using SignalR
Using the SignalR library it’s possible to push notifications from the server to the clients. In this post I’m going to show how you can publish notifications about newly published documents to a site front page. For this to happen we need to add four pieces of code: 1. A SignalR Hub that transports messages […]
Read moreUsing SignalR to build an Api (in Umbraco, WebMatrix or MVC)
I wrote a blog post the other day about using plain Razor scripts to create an easy to maintain Api on an Umbraco site. It’s a very straight forward way to make ajax-calls possible. However in reality I think many would say razor files is just not the right choice for server functionality like this, […]
Read moreA simple razor api : JSON Poco’s in Umbraco / WebMatrix
I’m rebuilding some ajaxy stuff on an Umbraco site using Knockout to spice up the UX. And I wanted a nice way to write my api functions. I tried several different approaches (Base, SignalR, WebApi), but in the end I got back to simple Razor scripts with a tiny twist. 1. Reserve a /macroScripts/api/ path […]
Read moreUsing SignalR with Umbraco to broadcast messages (or chat) [15 minutes]
My goal with this is to have a way to send messages from running tasks to me (and other admins) using a broadcast method … aswell as have some fun playing with SignalR which looks really cool . Just by adding the SignalR dll and js files and some minimal code you’ll get started with […]
Read moreSeparating html and logic in Razor (WebPages or Umbraco macroscript)
Mixing logic and html can easily end up with messy, hard-to-maintain code. In MVC it’s easy to separate the parts with the controller / view-separation. But how to do it nicely in WebPages or in an Umbraco macroscript? Ultimately I want my Razor to be free from variable assignments other than for loop iterators function […]
Read more
May 22, 2013 