<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rssdatehelper="urn:rssdatehelper" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Refactored i.T</title><link>http://refactored.com.au</link><pubDate>2011-12-16T21:09:45</pubDate><generator>umbraco</generator><description>Refactored Information Technology articles, HOWTO's and news</description><language>en</language><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/RefactoredIt" /><feedburner:info uri="refactoredit" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>Windows 8 DP with Boot Camp 4.0</title><link>http://feedproxy.google.com/~r/RefactoredIt/~3/9Prt74OQoaI/</link><pubDate>Fri, 16 Dec 2011 20:58:00 GMT</pubDate><guid isPermaLink="false">http://refactored.com.au/blog/2011/12/16/windows-8-dp-with-boot-camp-40/</guid><description>&lt;p&gt;Today I downloaded the Apple Boot Camp 4.0 using the BootCamp
Assistant in OSX Lion with the intention of installing it on my
Windows 8 Developer Preview.&amp;nbsp; After burning it to CD and
re-booting in Windows 8, I discovered that Boot Camp 4.0 only
supports Windows 7, and promptly refused to install under Windows
8.&lt;/p&gt;

&lt;p&gt;After searching the 'net for a solution to no avail (the best
advice on offer was to go into the Drivers directory and install
each one individually), I tried something radical.&amp;nbsp; I turned
on the Compatibility settings for the actual BootCamp64.MSI. Lo and
behold, it worked! Boot Camp proceeded to install itself and the
relevant drivers without a hitch.&lt;/p&gt;

&lt;p&gt;So here's the process:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Navigate to the folder containing the BootCamp MSI files&lt;/li&gt;

&lt;li&gt;Right-click on the relevant BootCamp[64].msi file for your
system (i.e., if you are running 32-bit Windows, select the
BootCamp.msi file)&lt;/li&gt;

&lt;li&gt;Open up the Properties dialog and go to the Compatibility
tab.&lt;/li&gt;

&lt;li&gt;Turn Compatibility Mode on (select "Run this program in
compatility mode for:") and choose "Previous version of Windows" in
the drop down (actually, it's probably the only choice available to
you).&lt;/li&gt;

&lt;li&gt;Click OK, and go run the installer again.&lt;/li&gt;

&lt;li&gt;Restart your computer, and enjoy.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's about it.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RefactoredIt/~4/9Prt74OQoaI" height="1" width="1"/&gt;</description><feedburner:origLink>http://refactored.com.au/blog/2011/12/16/windows-8-dp-with-boot-camp-40/</feedburner:origLink></item><item><title>Introducing the Umbraco View Counter</title><link>http://feedproxy.google.com/~r/RefactoredIt/~3/EbbkH8syHnM/</link><pubDate>Mon, 14 Nov 2011 01:12:00 GMT</pubDate><guid isPermaLink="false">http://refactored.com.au/blog/2011/11/14/introducing-the-umbraco-view-counter/</guid><description>&lt;p&gt;Over the last couple of days we've been busy creating an Umbraco
package that deals with Content View Counters - it enables the web
master to track the number of times content has been viewed on the
site.&lt;/p&gt;

&lt;p&gt;The Documentation and package has just been uploaded to the
Umbraco Project Repository and can be downloaded from &lt;a
href="http://our.umbraco.org/projects/website-utilities/refactored-content-views"
 target="_blank" title="Refactored Content Views"&gt;here&lt;/a&gt;.&amp;nbsp;
This post deals with a few of the features of the package, which
was built agains Umbraco 4.7 and dotNet 4.0&lt;/p&gt;

&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;TheRefactored Content Viewspackage is essentially a content
views (number of times&amp;nbsp; viewed) counter.&amp;nbsp; The current
functionality offered by this package includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Optional Data Type that allows for configuring view counters
with various categories and the ability to instruct Macros etc. to
"hide" the view Count yet still increment it.&lt;/li&gt;

&lt;li&gt;Optional incrementing when displaying the view count (useful
when you want to display the view count in a content listing, for
example)&lt;/li&gt;

&lt;li&gt;Example Razor Script and Macro.&lt;/li&gt;

&lt;li&gt;Library methods to manipulate the counters and retrieve details
as an XML fragment for use with XSLT.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Basic Usage.&lt;/h2&gt;

&lt;p&gt;To simply retrieve and/or increment the counter for a specific
content item, call the following library method.&amp;nbsp; The category
and increment parameters are optional, with default values shown
initalics:&lt;/p&gt;

&lt;pre class="brush: c-sharp;"&gt;
ViewCount.GetViewCount(nodeId, category: "&amp;lt;empty string&amp;gt;", increment: false);
&lt;/pre&gt;

&lt;p&gt;There is no requirement to configure a DataType; supplying the
node id of any valid Content-based node (Member, Document, Media,
etc.) will create the Views record in the database if it doesn't
exist.&amp;nbsp; However configuring and using a DataType will allow
you to control the advanced features of the counter.&lt;/p&gt;

&lt;h2&gt;Out of the box&lt;/h2&gt;

&lt;p&gt;Out of the box you get a default DataType (View Count) and a
sample Razor Macro that displays the current View Count of the node
being displayed.&amp;nbsp; If you have set up the Document Type with
the View Count DataType, the macro will check whether the View
Count should be displayed or not.&lt;/p&gt;

&lt;h3&gt;Macro Parameters for Page Views:&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Category (text) - optionally specifies the Category to record
the Page Count against.&lt;/li&gt;

&lt;li&gt;Increment (bool) - set to true to increment the Page Count when
the macro is called.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Macro Script Contents:&lt;/h3&gt;

&lt;pre class="brush: c-sharp;"&gt;
@inherits umbraco.MacroEngines.DynamicNodeContext
@using umbraco.MacroEngines;
@using umbraco.NodeFactory;
@using Refactored.UmbracoViewCounter;

@if (!ViewCount.HideCounter(Model.Id, category: Parameter.Category)) {
  &amp;lt;span&amp;gt;# Views:@ViewCount.GetViewCount(@Model.Id, category: @Parameter.Category, increment: @Parameter.Increment == "1").ToString("N0")&amp;lt;/span&amp;gt;
} else {
  ViewCount.Increment(Model.Id, category: Parameter.Category);
}
&lt;/pre&gt;

&lt;h2&gt;&amp;nbsp;Setting up a Data Type&lt;/h2&gt;

&lt;p&gt;The Data Type has the following Parameters:&lt;/p&gt;

&lt;p&gt;&lt;img src="/media/3098/fig_1_499x273.jpg"  width="499"  height="273" alt="View Count DataType" style="display: block; margin-left: auto; margin-right: auto;"/&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Category- Specifyinga different category for multiple DataTypes
allows you to differentiate between multiple View Counts in a
single content item.&amp;nbsp; You can then render the content in
different views and have a different View Count for each
rendering.&lt;/li&gt;

&lt;li&gt;Hide View Count- Allows you to control (in conjunction with the
API and Razor or XSLT macros, for example) whether to hide or show
the view count at a Data Type level.&lt;/li&gt;

&lt;li&gt;Enable View History- Turns on recording of View Count History
data including the time the view was incremented.&amp;nbsp; Also
recorded is Reset command events.&amp;nbsp; This data is stored in the
refViewCountHistory table and persists even if the current view
count is reset.&amp;nbsp; This is off by default.&lt;/li&gt;

&lt;li&gt;Disable Counter Reset- Turning this on disables the Reset
action on Content configured with a View Count DataType.&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/RefactoredIt/~4/EbbkH8syHnM" height="1" width="1"/&gt;</description><feedburner:origLink>http://refactored.com.au/blog/2011/11/14/introducing-the-umbraco-view-counter/</feedburner:origLink></item><item><title>The Playground - interactive Canvas goodness</title><link>http://feedproxy.google.com/~r/RefactoredIt/~3/TW1CLysh514/</link><pubDate>Wed, 31 Aug 2011 02:55:00 GMT</pubDate><guid isPermaLink="false">http://refactored.com.au/blog/2011/8/31/the-playground-interactive-canvas-goodness/</guid><description>&lt;p&gt;We've just created a &lt;a href="/the-playground/" target="_blank"
title="The Playground"&gt;Playground&lt;/a&gt; for testing out Javascript
and the Canvas tag with &lt;a href="http://raphaeljs.com/index.html"
target="_blank" title="Raphaël-JavaScript Library"&gt;Raphaël&lt;/a&gt; and
&lt;a href="http://easeljs.com/" target="_blank"
title="EaselJS: A Javascript Library for Working with the HTML5 Canvas Element."&gt;
EaselJS&lt;/a&gt;... At the moment, we're still loading example code to
use with the playground, however there is also a default "blank"
sandbox that you can use to test your own code in provided as
well.&lt;/p&gt;

&lt;p&gt;The feature set will grow over time, including contributing your
own examples; however for now feel free to have a play and leave a
comment here with any suggestions for features or code samples you
may like to share.&lt;/p&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RefactoredIt/~4/TW1CLysh514" height="1" width="1"/&gt;</description><feedburner:origLink>http://refactored.com.au/blog/2011/8/31/the-playground-interactive-canvas-goodness/</feedburner:origLink></item><item><title>High School Students and the Internet - not just consumers</title><link>http://feedproxy.google.com/~r/RefactoredIt/~3/pyv0zF0he0I/</link><pubDate>Thu, 25 Aug 2011 07:22:00 GMT</pubDate><guid isPermaLink="false">http://refactored.com.au/blog/2011/8/25/high-school-students-and-the-internet-not-just-consumers/</guid><description>&lt;p&gt;Yesterday I met with the local High School to discuss the
possibilities of getting involved by running programs for
interested students in the areas of web and games
development.&amp;nbsp; During the course of the meeting, I was asked to
come up with a few paragraphs that the staff could use when
promoting these programs, so I thought I'd put it up here (partly
to help consolidate my thoughts into a hopefully cohesive
introduction rather than just rambling on...).&amp;nbsp; So here
goes.&amp;nbsp; Any constructive comments or suggestions are entirely
welcome, so please don't be shy - jump right in to the
conversation!&lt;/p&gt;

&lt;p&gt;First a little background.&amp;nbsp; The school, Lara Secondary
College in Victoria, Australia is really what you would call a
regional school - Lara is situated outside of the nearest large
city (Geelong) and is considered to be "The country between the
cities" to quote one local resident.&amp;nbsp; While Lara is by no
means a small country town and is rapidly growing, it still retains
that small town community atmosphere.&amp;nbsp; The school itself has a
Connections program for Year 9 Students running for a good part of
the year one day a week, in which students are encouraged to take
on projects that directly benefit the community in some way.&lt;/p&gt;

&lt;p&gt;My original vision for setting up a what might look like a club
within the school was to teach students some of the more cutting
edge web technologies focussing on two areas:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Web page layout and design utilising HTML5 and CSS3, and&lt;/li&gt;

&lt;li&gt;Online Games development utilising open source javascript
frameworks and tools.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We would do this by coming up with a project that would benefit
the community in some way - perhaps by re-desiging one of the local
not-for-profit community organisations, or by designing a game with
an educational focus to be used by the wider school community (and
even by other schools)&lt;/p&gt;

&lt;p&gt;So this is what I have come up with to introduce students to the
idea and to generate some interest:&lt;/p&gt;

&lt;p style="text-align: center;"&gt;. o o o 0 0 &lt;strong&gt;O&lt;/strong&gt; 0 0 o
o o .&lt;/p&gt;

&lt;p&gt;Online Computing these days is pervasive in all areas of our
daily lives - whether it be reading emails or chatting on Facebook,
or perhaps playing your favourite game of Pac Man, the humble Web
Browser is fast becoming less of an application in its own right
and taking a seat in the background while it acts as simply a host
to highly interactive and expressive web-based applications.&amp;nbsp;
These days you can play games and watch movies; connect with people
from across the globe; or just write that business document - all
from within one of the popular Web Browsers without having to
install a thing.&lt;/p&gt;

&lt;p&gt;Today we have tools freely available within our grasp to not
only create visually compelling web sites, but also make those
websites dynamically interactive with video, sound, and
animation.&amp;nbsp; There are tools and frameworks upon which games
are being built, and high quality graphics can be rendered right
within the browser window.&amp;nbsp; In fact, you can author a complete
website&amp;nbsp; from scratch without having to open anything more
than your favourite browser.&lt;/p&gt;

&lt;p&gt;JavaScript - the programming language of the web browser - can
be used to program a website to pull information and present it
from sources all over the web - want your Facebook status displayed
on your website? no problem.&amp;nbsp; Perhaps you have uploaded a new
YouTube video and want to embed it on your site. Easy.&amp;nbsp; Or
maybe you want to be able to plot geographical data and connect the
dots with Google Maps.&amp;nbsp; JavaScript can be used to do all this
and more.&lt;/p&gt;

&lt;p&gt;We are looking for a group of students with an interest in
computing, and who have a passion to do more than just use the web
- they want to build it.&amp;nbsp; Students will gain an understanding
of the building blocks of a website, and we then go beyond that to
examine what it takes to create a game from scratch that can be
used to deliver value to the wider community.&amp;nbsp; We will also
have professionals who are experts in their field come in and hold
workshops in the areas of Graphic Design and Web Development.&lt;/p&gt;

&lt;p style="text-align: center;"&gt;. o o o 0 0 &lt;strong&gt;O&lt;/strong&gt; 0 0 o
o o .&lt;/p&gt;

&lt;p&gt;That's it.&amp;nbsp; If anyone has anything to add, or any other
comments, suggestions or thoughts, please, drop me a line...&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RefactoredIt/~4/pyv0zF0he0I" height="1" width="1"/&gt;</description><feedburner:origLink>http://refactored.com.au/blog/2011/8/25/high-school-students-and-the-internet-not-just-consumers/</feedburner:origLink></item><item><title>Blog 4 Umbraco Extensions Documentation</title><link>http://feedproxy.google.com/~r/RefactoredIt/~3/CszkR-arAk8/</link><pubDate>Thu, 30 Jun 2011 18:38:00 GMT</pubDate><guid isPermaLink="false">http://refactored.com.au/blog/2011/6/30/blog-4-umbraco-extensions-documentation/</guid><description>&lt;p&gt;Finally, some 8 months after the Blog4Umbraco Extensions library
became available, I decided to post it to the package repository on
&lt;a
href="http://our.umbraco.org/projects/collaboration/refactored-blog4umbraco-extensions"
 target="_blank"
title="Our.Umbraco - Refactored Blog4Umbraco Extensions"&gt;our.umbraco.org&lt;/a&gt;
and create some actual documentation for it - this is the
result...&lt;/p&gt;

&lt;p&gt;This document may also be downloaded as a PDF from &lt;a
href="/media/2950/blog4umbraco_extensions_post_installation_guide.pdf"
 target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;The Refactored Blog4Umbraco Extensions came about because the
current version of Blog4Umbraco (currently 2.0.26) had some issues
when it came to creating multiple blogs within a single website,
and in addition under some circumstances creating a new blog entry
would cause a "Yellow Screen of Death" (YSod).&lt;/p&gt;

&lt;p&gt;In order to address these shortcomings this package was created,
and later extended with other functionality.&amp;nbsp; The current
functionality offered by this package includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Allowing Comments to be Disabled at the Blog Level&lt;/li&gt;

&lt;li&gt;Enable setting a Blog-wide Category and having Tags bound to
that Category&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An additional Datatype called Blog Tags and derived from the
built in Tags Datatype is also provided which is the basis upon
which the Blog-wide Category is built.&lt;/p&gt;

&lt;p&gt;For a more detailed and technical description of the package,
the reader is directed to the blog entries found at &lt;a
href="/blog"&gt;/blog&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a
href="/blog/2010/10/19/blog-categories-in-blog4umbraco-take-two/"&gt;Blog
Categories in Blog4Umbraco - Take Two&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a
href="/blog/2010/10/18/adding-a-blog-category-to-blog4umbraco/"&gt;Adding
a Blog Category to Blog4Umbraco&lt;/a&gt; (the method described here is
not recommended, but provides additional background
information).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;The Future&lt;/h2&gt;

&lt;p&gt;Work is currently underway to release a version 3 of
Blog4Umbraco (B4U) which will address the issues discussed here and
add other much needed functionality including Trackbacks and
Comment Notifications.&lt;/p&gt;

&lt;h2&gt;Post-Installation Steps&lt;/h2&gt;

&lt;p&gt;After installing the package, additional steps are required in
order to activate the features.&amp;nbsp; These involve modifying the
Blog-related document types as follows:&lt;/p&gt;

&lt;h3&gt;Globally Disabling Comments&lt;/h3&gt;

&lt;p&gt;In order to be able to globally disable comments, edit the Blog
Document Type by adding a new property based on the True/False data
type as follows:&lt;/p&gt;

&lt;p style="text-align: center;"&gt;&lt;img src="/media/2927/blogdisablecomments.png" width="474" height="299" alt="Blog DisableComments Property"/&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;If the Disable Comments checkbox is checked on a Blog page then
the Close comments field will be also become checked when it is
saved.&lt;/p&gt;

&lt;h3&gt;Blog Categories&lt;/h3&gt;

&lt;h4&gt;Updating the Blog Document Type&lt;/h4&gt;

&lt;p&gt;In order to facilitate Blog Categories, an additional property
needs to be added to the Blog Document Type as follows:&lt;/p&gt;

&lt;p style="text-align: center;"&gt;&lt;img src="/media/1976/blogcategory.png" width="404" height="299" alt="BlogCategory"/&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Coupled with the change to the Blog Post Document type below,
this will cause tags added to blog posts to use the category set in
this property of the corresponding Blog.&lt;/p&gt;

&lt;h4&gt;Updating the Blog Post Document Type&lt;/h4&gt;

&lt;p&gt;Change the Tags property in the Blog Post Document so that it
uses the "Blog Tags" type instead of the built-in "Tags" data
type:&lt;/p&gt;

&lt;p style="text-align: center;"&gt;&amp;nbsp;&lt;img src="/media/2933/blogposttags.png" width="421" height="150" alt="blogPost Blog Tags"/&gt;&lt;/p&gt;

&lt;h3&gt;Enabling Time fields in the Blog Entry Post Date&lt;/h3&gt;

&lt;p&gt;In the original Blog4Umbraco package, there is no way to enable
the Post Date to use time as well as date, which results in all
posts being set as being posted at midnight.&amp;nbsp;&lt;/p&gt;

&lt;p&gt;The updated Umlaut.Umb.Blog.dll file included in this package
addresses this issue, but you still need to modify the Blog Post
document type in order to take advantage of the change.&amp;nbsp; In
order to do so, change the Post Date property type from "Date
Picker" to "Date Picker with time":&lt;/p&gt;

&lt;p style="text-align: center;"&gt;&lt;img src="/media/2939/blogpost_postdate.png" width="404" height="152" alt="blogPost PostDate Property"/&gt;&amp;nbsp;&lt;/p&gt;

&lt;h2&gt;Other Issues:&lt;/h2&gt;

&lt;h3&gt;Blog for Umbraco generates the following error when attempting
to create a new Blog:&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Issue # 5612 - &lt;a
href="http://blog4umbraco.codeplex.com/workitem/5612"
target="_blank"&gt;http://blog4umbraco.codeplex.com/workitem/5612&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;
Operand type clash: int is incompatible with ntext&lt;br /&gt;
 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.&lt;br /&gt;
&lt;br /&gt;
 Exception Details: System.Data.SqlClient.SqlException: Operand type clash: int is incompatible with ntext
&lt;/pre&gt;

&lt;h4&gt;Workaround:&lt;/h4&gt;

&lt;p&gt;If you encounter this type of error, double-check the Author
Picker and make sure that the datatype is set tointinstead
ofntext.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RefactoredIt/~4/CszkR-arAk8" height="1" width="1"/&gt;</description><feedburner:origLink>http://refactored.com.au/blog/2011/6/30/blog-4-umbraco-extensions-documentation/</feedburner:origLink></item><item><title>Conditionally disabling Ajax in MVC3 Forms</title><link>http://feedproxy.google.com/~r/RefactoredIt/~3/0EpGRSgYa4c/</link><pubDate>Mon, 06 Jun 2011 01:55:00 GMT</pubDate><guid isPermaLink="false">http://refactored.com.au/blog/2011/6/6/conditionally-disabling-ajax-in-mvc3-forms/</guid><description>&lt;p&gt;While working with MVC3 and Razor views recently, we came across
the need to disable the Ajax behaviour in a form when the user
pressed a certain submit button.&amp;nbsp; To give you some background,
we were working on a Shopping Cart whereby the user had the
following possible actions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Edit an item,&lt;/li&gt;

&lt;li&gt;Delete an item&lt;/li&gt;

&lt;li&gt;Update the quantity of an item,&lt;/li&gt;

&lt;li&gt;Submit the cart to Checkout&lt;/li&gt;

&lt;li&gt;Clear the cart&lt;/li&gt;

&lt;li&gt;Refresh the cart.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, for most cases, we wanted the cart to be refreshed without
the user having to see a post back, so Ajax was the best way to
handle this, of course.&amp;nbsp; Although the application is based on
the Umbraco CMS, we developed the e-Commerce side of things in MVC3
from scratch and integrated it with Umbraco using the excellent &lt;a
href="http://our.umbraco.org/projects/developer-tools/mvcbridge"
target="_blank" title="MvcBridge"&gt;MVCBridge&lt;/a&gt; add-on.&amp;nbsp; This
allowed us to take advantage of all MVC has to offer.&amp;nbsp;
However, the solution that follows is not dependant on Umbraco or
MVCBridge at all.&lt;/p&gt;

&lt;p&gt;Because this is a new project and has no legacy MVC code in it,
we are able to take full advantage of the new &lt;a
href="http://bradwilson.typepad.com/blog/2010/10/mvc3-unobtrusive-ajax.html"
 target="_blank"
title="Unobtrusive Ajax in ASP.NET MVC 3"&gt;Unobtrusive Ajax&lt;/a&gt;
style for binding Ajax to the form.&amp;nbsp; This means that under the
hood we are using jquery's ajax engine only, and not the legacy
Microsoft one.&amp;nbsp; Here's the basic form:&lt;/p&gt;

&lt;pre class="brush: xhtml;"&gt;
@using (Ajax.BeginForm(new AjaxOptions
{
    OnSuccess = "updateCart"
}))
{

    @Html.RenderFormToken();
&amp;lt;section id="shoppingCart"&amp;gt;
    &amp;lt;h1&amp;gt;Items in your Shopping Cart&amp;lt;/h1&amp;gt;
    &amp;lt;table cellpadding="0" cellspacing="0"&amp;gt;
    @foreach (var item in Model.Items.Values)
    {
        // Render the items, including the Edit, Delete and Update submit buttons...
    }
    &amp;lt;tr&amp;gt;
        &amp;lt;td colspan="3" class="totalValue"&amp;gt;Total Value:&amp;lt;/td&amp;gt;
        &amp;lt;td class="totalValue"&amp;gt;@Html.DisplayFor(model =&amp;gt; model.TotalIncTax)
        @Html.HiddenFor(model =&amp;gt; model.TotalItemCount)
        @Html.HiddenFor(model =&amp;gt; model.TotalIncTax)&amp;lt;/td&amp;gt;
        &amp;lt;td class="totalValue"&amp;gt;&amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
    &amp;lt;/table&amp;gt;
    &amp;lt;span class="submit"&amp;gt;&amp;lt;input type="submit" value="Refresh Cart" name="refresh" id="refresh" /&amp;gt;
    &amp;lt;input type="submit" value="Clear" name="reset" id="reset" /&amp;gt;
    &amp;lt;input type="submit" value="Checkout" name="checkout" id="checkout" /&amp;gt;&amp;lt;/span&amp;gt;
&amp;lt;/section&amp;gt;
}
&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
 Now, when a user presses any of the submit buttons, the form will
be posted back to the server, and the new page content will be
returned to the updateCart function so that we can update the
user's view without having to refresh the page.&lt;/p&gt;

&lt;p&gt;But we want the item Edit and the Checkout buttons to re-direct
to a new page instead of submitting back to the shopping
cart.&amp;nbsp; For that to happen, we need to do two things (let's
focus on the Checkout button, which we want to re-direct to the
Checkout page):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the ShoppingCartController we need to check which submit
button was pressed by inspecting the form elements, and do a
Resonse.Redirect() to the appropriate page if the user pressed the
Checkout button, for example; and&lt;/li&gt;

&lt;li&gt;Disable the Ajax behaviour when the user presses the Checkout
button.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The code to handle the second step is as follows:&lt;/p&gt;

&lt;pre class="brush: javascript;"&gt;
   // These variables are defined here as they may be referenced in other code blocks.
   // The $().ready function is used to populate them.
    var cartSection = null;
    var eShopCartForm = null;

    $(document).ready(function () {
        cartSection = $("#shoppingCart");
        eShopCartForm = cartSection.closest("form");

        // Disable the ajax behaviour if the checkout button is pressed.  We want the form
        // to submit normally so that the page can be redirected. 
        var checkoutSubmit = cartSection.find("#checkout");

        // We supply our own handler for this button to remove the form's ajax submit handler.
        checkoutSubmit.live("click", function (evt) {
            // Setting this attribute to false means the ajax form submit handler won't be triggered...
            eShopCartForm.attr("data-ajax", "false");
        });
    });
&lt;/pre&gt;

&lt;p&gt;If you care to dig deeper, then I recommend taking a look
through the jquery.unobtrusive-ajax.js file that is bundled with
the MVC3 projects.&amp;nbsp; Basically though we are changing the
data-ajax attribute that is generated on the form element when the
user clicks the checkout button so that the ajax submit handler
doesn't trigger.&lt;/p&gt;

&lt;p&gt;There you have it.&amp;nbsp; Any questions, suggestions, remarks,
please leave a comment...&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RefactoredIt/~4/0EpGRSgYa4c" height="1" width="1"/&gt;</description><feedburner:origLink>http://refactored.com.au/blog/2011/6/6/conditionally-disabling-ajax-in-mvc3-forms/</feedburner:origLink></item><item><title>Resetting IE9's Javascript Engine</title><link>http://feedproxy.google.com/~r/RefactoredIt/~3/gP0pOddveTc/</link><pubDate>Thu, 19 May 2011 17:25:00 GMT</pubDate><guid isPermaLink="false">http://refactored.com.au/blog/2011/5/19/resetting-ie9's-javascript-engine/</guid><description>&lt;p&gt;Quick post this time - lately I've come across this obscure
error in Javascript with Internet Explorer 9 whenever I tried to
run a jQuery ligthbox script:&lt;/p&gt;

&lt;pre&gt;
appendChildOriginal(element);&lt;br /&gt;
&lt;br /&gt;
jscript debugger&lt;br /&gt;
breaking on jscript runtime error - invalid calling object
&lt;/pre&gt;

&lt;p&gt;after tearing my hair out and "researching" the problem on
Google, I came across this obscure solution:&lt;/p&gt;

&lt;pre&gt;
IE:&amp;nbsp; Tools-&amp;gt;Options Advanced Settings "Reset"
&lt;/pre&gt;

&lt;p&gt;(found here: "&lt;a href="http://forums.asp.net/t/1664964.aspx/1"
target="_blank" title="Microsoft J"&gt;Microsoft J&lt;/a&gt;")&lt;/p&gt;

&lt;p&gt;Seems that all that is needed to fix the problem is resetting
the Internet Explorer settings fixes the problem.&lt;/p&gt;

&lt;p&gt;A translation of the line above is as follows:&lt;/p&gt;

&lt;p&gt;In Internet Explorer 9, Open the "Internet Options" either from
the Tools menu (hit ALT to make the menu appear) or the "Cog" icon
drop down.&lt;/p&gt;

&lt;p&gt;Go to the Advanced Tab, and hit the "Reset..." button.&amp;nbsp; On
the dialog that pops up, hit "Reset" again.&lt;/p&gt;

&lt;p&gt;That's it. problem solved.&amp;nbsp; No need to reinstall IE 9.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RefactoredIt/~4/gP0pOddveTc" height="1" width="1"/&gt;</description><feedburner:origLink>http://refactored.com.au/blog/2011/5/19/resetting-ie9's-javascript-engine/</feedburner:origLink></item><item><title>Umbraco and JSON-RPC</title><link>http://feedproxy.google.com/~r/RefactoredIt/~3/hGL_g6XqudY/</link><pubDate>Wed, 18 May 2011 02:36:00 GMT</pubDate><guid isPermaLink="false">http://refactored.com.au/blog/2011/5/18/umbraco-and-json-rpc/</guid><description>&lt;p&gt;We recently created a companion iPhone application for a website
we released late last year, which needed to retrieve content from
the website.&amp;nbsp; Rather than just retrieve pages of information
as html, we wanted to display lists of content, and we also wanted
to cache the content on the device for offline viewing.&amp;nbsp; To do
this, it was decided we would use JSON as the transport as it is
lightweight.&lt;/p&gt;

&lt;p&gt;On the client side, we used the &lt;a
href="http://stig.github.com/json-framework" target="_blank"
title="JSON-Framework"&gt;JSON-Framework&lt;/a&gt; Cocoa based library
created by Stig Brautaset.&amp;nbsp; On the server side we used JayRock
&lt;a href="http://jayrock.berlios.de/" target="_blank"
title="Jayrock: JSON and JSON-RPC"&gt;JSON-RPC&lt;/a&gt; library for dotNet.
Oh, and the website was based on the Umbraco CMS.&lt;/p&gt;

&lt;h2&gt;Background on JSON-RPC&lt;/h2&gt;

&lt;p&gt;The &lt;a href="http://json-rpc.org/wiki/specification"
target="_blank" title="JSON-RPC Specification"&gt;JSON-RPC
specification&lt;/a&gt; is fairly straightforward - it consists of a
request, a response, and a notification.&amp;nbsp; The request sent to
the server has 3 parameters as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Method Name&lt;/li&gt;

&lt;li&gt;Parameters, and&lt;/li&gt;

&lt;li&gt;Id - This is used to associate the request with it's respective
reply, and provided it is unique can be used to quarantee that the
calling code receives the correct reply for the request - very
important if you are sending multiple requests asynchronously.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The response from the server also has 3 parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Result object - the result in JSON notation&lt;/li&gt;

&lt;li&gt;Error object - if an error is thrown by the called method, the
details will be contained in this object, including any exceptions
thrown, which is very useful for debugging&lt;/li&gt;

&lt;li&gt;Id - this is the same as the id passed in with the
Request.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Creating a JSON-RPC Service&lt;/h2&gt;

&lt;p&gt;Using the JayRock library, this is all encapsulated, and we can
just go about writing our Service Methods like so:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In Visual Studio, or your favourite editor, start by creating a
Generic Handler (.ashx type).&lt;/li&gt;

&lt;li&gt;Change the class definition so that it derives from the
&lt;strong&gt;JsonRpcHandler&lt;/strong&gt; class instead&lt;/li&gt;

&lt;li&gt;Create your Method declarations as per normal, but decorate
them with the JsonRpcMethod Attribute.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An example is as follows (this is the base class we have created
for authenticating user requests to the Umbraco backend):&lt;/p&gt;

&lt;pre class="brush: c-sharp;"&gt;
using System.Web.Security;
using Jayrock.JsonRpc;
using Jayrock.JsonRpc.Web;
using System;
using System.Web;

namespace refactored.WebServices.json
{
    /// &amp;lt;summary&amp;gt;
    /// Provides a base class for JSON-RPC Services and handles authentication.
    /// &amp;lt;/summary&amp;gt;
    public class BaseJSONService : JsonRpcHandler
    {
        protected string AuthenticationToken { get; set; }

        [JsonRpcMethod("AuthenticateMember")]
        public string AuthenticateMember(string username, string password)
        {
          ..&lt;br /&gt;
          ..&lt;br /&gt;
        }

        [JsonRpcMethod("AuthenticationExpired")]
        public bool AuthenticationExpired(string authToken)
        {
            return (HttpRuntime.Cache[authToken] == null);
        }&lt;br /&gt;
       &amp;nbsp;protected bool IsUserValid()
        {
            return (!string.IsNullOrEmpty(AuthenticationToken) &amp;amp;&amp;amp; !AuthenticationExpired(AuthenticationToken));
        }

        protected string GetUserName()
        {
            if (IsUserValid())
                return HttpRuntime.Cache[AuthenticationToken].ToString();
            else
                return string.Empty;
        }

        protected MembershipUser GetMember() {
            if (IsUserValid())
                return Membership.GetUser(GetUserName());
            else
                return null;
        }
        private bool ValidateUser(string username, string password) {
            return Membership.ValidateUser(username, password);
        }
    }
}
&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/p&gt;

&lt;p&gt;Once you compile and load the dll into Umbraco, along with the
associated ashx file, you can test the webservice in your favourite
web browser:&lt;/p&gt;

&lt;p&gt;&lt;img src="/media/2460/screen shot 2011-05-18 at 3.36.03 am_499x510.jpg"  width="499"  height="510" alt="JSON-RPC Service Discovery"/&gt;&lt;/p&gt;

&lt;h2&gt;User Authentication and Web Services&lt;/h2&gt;

&lt;p&gt;One of the features of the iPhone Application was that it
allowed users to provide feedback on the content, as well as create
"favourite" lists.&amp;nbsp; This required that users be able to
authenticate with the website in order to make changes to their
profile and update the lists on the website.&lt;/p&gt;

&lt;p&gt;Because Web Services cannot store the users session, we need to
provide some way of authenticating the user each call. In order to
do this, an AuthenticateMember(string username, string password)
method was created on the Service that returned an authentication
token to be used in subsequent calls:&lt;/p&gt;

&lt;pre class="brush: c-sharp;"&gt;
        [JsonRpcMethod("AuthenticateMember")]
        public string AuthenticateMember(string username, string password)
        {
            if (string.IsNullOrEmpty(username) || !ValidateUser(username, password))
                throw new Exception("Your Username or Password is incorrect");

            // Create and store the AuthenticatedToken before returning it
            AuthenticationToken = Guid.NewGuid().ToString();
            HttpRuntime.Cache.Add(
                   AuthenticationToken,
                   username,
                  null,
                  System.Web.Caching.Cache.NoAbsoluteExpiration,
                   TimeSpan.FromMinutes(60),
                  System.Web.Caching.CacheItemPriority.NotRemovable,
                  null);

            return AuthenticationToken;
        }
&lt;/pre&gt;

&lt;p&gt;Then, on subsequent calls, we just pass the authentication token
in to be validated against the cached version.&lt;/p&gt;

&lt;p&gt;Lets test out the method:&lt;/p&gt;

&lt;p&gt;&lt;img src="/media/2472/screen shot 2011-05-18 at 3.38.43 am_498x495.jpg"  width="498"  height="495" alt="JSON-RPC Service Testing with error"/&gt;&lt;/p&gt;

&lt;p&gt;Notice wth this screen shot that the returned result was
actually the error - it even includes the Exception details along
with the erorr message.&lt;/p&gt;

&lt;p&gt;Fixing up the parameters results in the following:&lt;/p&gt;

&lt;p&gt;&lt;img src="/media/2478/screen shot 2011-05-18 at 3.41.54 am_498x495.jpg"  width="498"  height="495" alt="JSON-RPC Service Testing with expected result"/&gt;&lt;/p&gt;

&lt;p&gt;Note the returned value - this is the authentication token
generated by the server - we use this when calling subsequent
methods that require validation.&lt;/p&gt;

&lt;p&gt;Well, that's it for now, hopefully you can see from this how we
can use JSON-RPC to retrieve information from a website and consume
it in other applications, or even using AJAX.&amp;nbsp; Not only can we
retrieve information, we can also create new content and otherwise
manipulate information on a website.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RefactoredIt/~4/hGL_g6XqudY" height="1" width="1"/&gt;</description><feedburner:origLink>http://refactored.com.au/blog/2011/5/18/umbraco-and-json-rpc/</feedburner:origLink></item><item><title>Embedded YouTube Videos and iPad Rotation</title><link>http://feedproxy.google.com/~r/RefactoredIt/~3/x6Vb3yvI3aQ/</link><pubDate>Tue, 29 Mar 2011 17:18:00 GMT</pubDate><guid isPermaLink="false">http://refactored.com.au/blog/2011/3/29/embedded-youtube-videos-and-ipad-rotation/</guid><description>&lt;p&gt;While working on the iPhone/iPad application for the
ChickenChannel website, I needed to have the embedded YouTube video
resize dynamically to fit properly and in proportion across the
screen of the device.&amp;nbsp; Moreover, the iPad allows for rotating
the view, and we needed the video to resize to accomodate both
orientations dynamically as you rotate the device.&lt;/p&gt;

&lt;p&gt;The Chicken Channel is written in Umbraco, and the iOS
application takes advantage of that by presenting existing pages
with a customised template.&amp;nbsp; So while you might look at a
recipe on the website and see the nice embedded Youtube video
(hidden behind a banner image that prompts you to click it to start
playing the video - this was covered in a post last November &lt;a
href="/blog/2010/11/26/embedded-youtube-videos-with-placeholder-images/"
title="Embedded Youtube Videos with Placeholder Images"&gt;here&lt;/a&gt;.),
the iPhone and iPad views are somewhat different.&lt;/p&gt;

&lt;h2&gt;Step 1: Make the video automatically fill the width of the
screen.&lt;/h2&gt;

&lt;p&gt;This was quite easy:&amp;nbsp; all I needed to do was clear the
width and height the enclosing div and the object tags and set the
width to 100% on the embed tag.&amp;nbsp; I could have set the height
as well, but given that there are 3 possible width with the
devices, and I'm "veiling" the page until it's loaded anyway, I
didn't see any point.&amp;nbsp; This displays a rather wide but short
video on the iPhone:&lt;/p&gt;

&lt;pre class="brush: xhtml;"&gt;
&amp;lt;div class="youTubePlayer"&amp;gt;
  &amp;lt;object class="youTubePlayer"&amp;gt;
    &amp;lt;param name="movie" value="http://www.youtube.com/v/rldN0jSBbZQ?fs=1&amp;amp;rel=0" /&amp;gt;
    &amp;lt;param name="allowFullScreen" value="true" /&amp;gt;
    &amp;lt;param name="allowscriptaccess" value="always" /&amp;gt;
    &amp;lt;embed class="youTubePlayer" src="http://www.youtube.com/v/rldN0jSBbZQ?fs=1&amp;amp;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="100%" /&amp;gt;
  &amp;lt;/object&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/p&gt;

&lt;h2&gt;Step 2: Use Javascript to add the aspect ratio back in (set the
Height).&lt;/h2&gt;

&lt;p&gt;Using jQuery this is a really simple excercise:&amp;nbsp; We simply
get the width of the window, and, because all our videos are in
16:9 aspect ratio, we use that to derive the height before applying
it to the relevant tags.&amp;nbsp; (Notice the embed and object tags
also have the &lt;strong&gt;class="youTubePlayer"&lt;/strong&gt; attribute
above?) - you'll also need to add the jQuery core library to your
page...&lt;/p&gt;

&lt;pre class="brush: xhtml;"&gt;
  &amp;lt;script type="text/javascript"&amp;gt;
    $(document).ready(function() {
      var newHeight = $(window).width()*9/16;
      if (newHeight &amp;gt; 500)
          newHeight = 500;
      $('.youTubePlayer').attr("height", newHeight);
    });
  &amp;lt;/script&amp;gt;      
&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/p&gt;

&lt;p&gt;Right, after testing a little, we notice that the page renders,
then the video gets lengthened to the correct ratio and all is good
in the world.&amp;nbsp; However, when rotating the iPad application,
the videos dimensions aren't resized along with the rest of the
content.&amp;nbsp; Actually, the video's width is resized, but the
height stays where we left it.&lt;/p&gt;

&lt;h2&gt;Step 3: Use the Resize event to adjust the aspect ratio on
Rotation&lt;/h2&gt;

&lt;p&gt;The final step to this process was to take advantage of the
UIWebView's resize javascript event to perform the resize
again:&lt;/p&gt;

&lt;pre class="brush: xhtml;"&gt;
  &amp;lt;script type="text/javascript"&amp;gt;
    $(window).resize(function() {
      var newHeight = $(window).width()*9/16;
      var oldHeight = $('div.youTubePlayer:first').attr("height");
      if (newHeight &amp;gt; 500)
          newHeight = 500;
      if (newHeight = oldHeight)
          return;
      $('.youTubePlayer').attr("height", newHeight);
    });
&amp;lt;/script&amp;gt;
&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/p&gt;

&lt;p&gt;After a little more testing (ie, me madly waving the iPad around
in the air and doing acrobatic contortions in the process) we have
established that the video now resizes gracefully when the device
is rotated to Portrait or Landscape mode.&amp;nbsp; All is better in
the world.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Side note:&lt;/strong&gt; While playing around with this, I
had a javascript &lt;strong&gt;alert(newHeight);&lt;/strong&gt; line in the
resizing code.&amp;nbsp; on my iPad with the shiny new iOS 4.3.1
installed just last night, this promptly caused the application to
crash.&amp;nbsp; I've submitted a bug report to Apple, and we'll see
how it goes.&lt;/p&gt;

&lt;p&gt;As always, comments and suggestions are always welcome.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RefactoredIt/~4/x6Vb3yvI3aQ" height="1" width="1"/&gt;</description><feedburner:origLink>http://refactored.com.au/blog/2011/3/29/embedded-youtube-videos-and-ipad-rotation/</feedburner:origLink></item><item><title>I love NuGet!</title><link>http://feedproxy.google.com/~r/RefactoredIt/~3/rNjWOIlfQMU/</link><pubDate>Sat, 12 Mar 2011 17:08:00 GMT</pubDate><guid isPermaLink="false">http://refactored.com.au/blog/2011/3/12/i-love-nuget!/</guid><description>&lt;p&gt;It's official.&amp;nbsp; &lt;a href="http://nuget.codeplex.com/"
target="_blank" title="NuGet"&gt;NuGet&lt;/a&gt; is now my all-time
favourite Visual Studio Add-on.&lt;/p&gt;

&lt;p&gt;The other day I was trying to upload a simple website to my
hosting platform, but was having trouble with the
dependencies.&amp;nbsp; As it happens, the hosting environment doesn't
have MVC3 installed, or SqlServer Ce 4 for that matter.&amp;nbsp; MVC
wasn't much of a problem, but the Ce database server on the other
hand - well.&amp;nbsp; That's a different story.&lt;/p&gt;

&lt;p&gt;Since the website was very simple in functionality - it provides
a form that users can fill out to be notified of developments for a
piece of real-estate in Melbourne's Yarra Valley region - and we
only had a day to build it, I thought the combination of MVC3 with
SqlServer Ce (we used the Code-First data model approach, which
worked out really well) would be a no-brainer.&lt;/p&gt;

&lt;p&gt;That was until I proceeded to upload the database, and started
having to hunt around for all the necessary dll's.&amp;nbsp; It wasn't
enough to just mark the dependencies so they would be copied to the
output directory, I actually had to go and manually hunt around for
additional dll's as well.&lt;/p&gt;

&lt;p&gt;Enter NuGet.&lt;/p&gt;

&lt;p&gt;Nuget allows you to download and automatically set up additional
packages and libraries with ease.&amp;nbsp; It takes care of the
dependencies, and updates your configuration files as well so you
can just start using the new functionality without having to worry
about web.config settings, for example.&lt;/p&gt;

&lt;p&gt;So.&amp;nbsp; I added the package for EFCodeFirst.SqlServerCompact
to the project, which resulted in all the dependencies being added
as well in one easy step, and then all I had to do was make a few
tweaks here and there and upload the changes.&amp;nbsp; Too easy!&lt;/p&gt;

&lt;p&gt;Thank you, &lt;a href="http://nuget.codeplex.com/" target="_blank"
title="NuGet"&gt;NuGet&lt;/a&gt;, you've just made my life that much
easier.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/RefactoredIt/~4/rNjWOIlfQMU" height="1" width="1"/&gt;</description><feedburner:origLink>http://refactored.com.au/blog/2011/3/12/i-love-nuget!/</feedburner:origLink></item></channel></rss>

