Monthly Archives

February 2014

Post JSON data to an MVC controller from a Kendo datasource

By | Uncategorized | 2 Comments

The default examples provided by Kendo are an excellent starting point for understanding how to implement it in your project. However, they cannot cover every scenario. One particularly common scenario is the need to send JSON data to fulfill a parameter. The dataType attribute applied to your data source or even your jQuery ajax call determines the format of the data it receives not what it sends. By default both methods send ‘post’ data to a controller as form data and ‘get’ as a querystring value. This is fine for simple requests that contain strings, integers, etc. But what if…

Read More

The Four Deadly Sins of LINQ Data Access: Part 2–Too Many Columns

By | News | No Comments

This is post 2 of 4 in the series “The Four Deadly Sins of LINQ” Introduction Last time I talked about the sin of Overly Chatty Queries and pointed out two other sins while showing an example of an Overly Chatty Query and how to fix it. One of those sins was the sin of Too Many Columns, and that’s what I’m going to discuss this time. Confession Here is the code snippet I showed last time which demonstrates how to eagerly load entities, ensuring you have all the data you need in a single query rather than requiring an…

Read More

Creating a Sitefinity layout widget with an HTML5 video background

By | Uncategorized | No Comments

Recently Sitefinity.com updated their site and with it came a change to their landing page slider. The slider has a looping HTML5 video playing in the background behind an interactive content slider. I thought the video idea was pretty neat so I sought to replicate it in the form of a Sitefinity layout widget. I’m sure the idea of having a video background may be terrifying to some with concerns to page load times and bandwidth consumption, however, if you take a look at the video used by Sitefinity you will notice that it is actually only a few hundred KB. While…

Read More

JavaScript Shortcuts

By | Uncategorized | No Comments

JavaScript is fun language. Some of its rules provide developers with the ability to use shortcuts when writing code. Here are a few of my favorites. || as a null coalescing operator A null coalescing operator returns the value to its right only if the value to its left is null. Here is an example of a null coalescing operator (??) in C#: 1.public string ToCsv(IEnumerable<string> values) 2.{ 3.    values = values ?? Enumerable.Empty<string>(); 4.    return String.Join(“,”, values); 5.} JavaScript does not have a null coalescing operator but we can take advantage of the fact that every value is inherently considered ‘truthy’…

Read More

Embedding Sitefinity Widget MVC Views in an External Assembly

By | Sitefinity | No Comments

As we saw in the previous post, you can override the default MVC Views of the Falafel Dashboard Widgets for Sitefinity that are served from the Embedded Resources of the assembly. But how did we get the views there in the first place, and how do we serve them to the Sitefinity widgets while allowing them to be overridden with the physical files? That’s what we will be exploring today. Embedded Resources The first step is of course to embed the views inside the assembly. This is as simple as adding the views to the assembly project, and setting the…

Read More

Enabling Kendo Grid CSV Downloads on iPad Mobile Safari

By | JavaScript | No Comments

Remember in my previous blog how we created a simple way to download the data from a Kendo Grid into a spreadsheet using csv?  Well, there is just one problem – it won’t work in mobile Safari.  This means that if you are viewing the Kendo Grid on an iPad, the spreadsheet generation will fail!  And that is too bad because if our site is Kendo-based it already looks great on the iPad, and a simple csv would be pretty darn useful. The problem is with the Blob support in mobile Safari.  We used Blob.js to make sure we could…

Read More

Don’t let those fixed position headers bother you

By | Sitefinity, Web | No Comments

What are fixed position headers? A common navigation paradigm now a days, thanks to Bootstrap, is “fixed navigation headers”. In this paradigm the navigation elements of the website are in a fixed position generally fixed to the top of the browser screen. See below for an illustration – See the header above and the content starts after that. And when you scroll to see more content The content scrolls but header stays where it is. Why is it a problem in Sitefinity’s context? Now this presents a tricky problem when dealing with templates in Sitefinity. If I were use this…

Read More

View Context for Kendo UI Mobile and MVVM

By | Kendo UI | No Comments

When using MVVM in Kendo UI Mobile, there are times where you will need the context of the view so you can make changes to it or read values from it. You can get the current view from the application’s “view()” method, but sometimes your app is not in the global namespace if you architected it this way. Unfortunately, this does not come as a parameter for your observable functions. So here’s the trick to finding the current view: <div id=”home” data-role=”view” data-model=”viewModel”>     <a href=”#” data-bind=”click: doSomething”>Do something with the view…</a> </div>   <script> var viewModel = kendo.observable({     doSomething: function…

Read More

Simultaneously capturing video from two (or more) web cams with Microsoft Expression Encoder

By | .NET, C# | No Comments

One of the solution to capture video with a USB camera is using Microsoft Expression Encoder  After adding references to these required assemblies Microsoft.Expression.Encoder Microsoft.Expression.Encoder.Types Microsoft.Expression.Encoder.Utilities var videoDevices = EncoderDevices.FindDevices(EncoderDeviceType.Video); First you receive a collection of available video capture devices and start a live job method for the encoder video = videoDevices[videoDeviceIndex]; _job = new LiveJob(); // Create a new device source. We use the first audio and video devices on the system _deviceSource = _job.AddDeviceSource(video, audio); _deviceSource.PickBestVideoFormat(new Size(640, 480), 15); // Get the properties of the device video SourceProperties sp = _deviceSource.SourcePropertiesSnapshot(); // Resize the preview panel to match…

Read More

Customizing the MVC Views of the Falafel Dashboard Widgets for Sitefinity

By | Sitefinity | No Comments

Last week, Falafel released the new Dashboard Widgets for Sitefinity, allowing you to easily add 11 new widgets to the administration dashboard for Sitefinity 6.2+. The widgets are easy to use and provide valuable information at a glance. But did you know they’re also highly customizable? Because these widgets are built with ASP.NET MVC, you can modify the View templates of each individual widget to change the layout to suit the visual needs of your site. In this post we’ll take a look at how you can achieve this. In a later post, we’ll look at the technical details that…

Read More

Image Correlation Math Utilities in C#

By | Uncategorized | No Comments

In this video I describe the basics of image correlation. I actually wrote these utilities over 15 years ago in Delphi. That’s the cool thing about math, it’s timeless. It doesn’t matter what you write it in.     Links  Statistical Functions Image Correlation Proof of Concept (Windows 8.1)       Image Correlation Function Details in C#

Read More

The easiest way to build Native iOS UI.

By | Xamarin | No Comments

When I first started working with iOS, the most difficult thing for me to grasp was the UI of the application. Not necessarily the widgets themselves, but implementing the MVC based navigation patterns and populating the UITableView – which is the staple of iOS data display and app navigation. You may have expected me to say Objective-C, well yes, that was a challenge, but I now have Xamarin.iOS to deal with that, and all my iOS code can be written in C#. Even with Xamarin.iOS and C#, populating a UITableView can be a daunting task, fraught with delegates (the iOS…

Read More

The Lo-Dash on Underscore.js and Strings

By | JavaScript | One Comment

If you are not using Underscore.js in your JavaScript development, then you are really missing out. It cuts out so much redundant functions you find yourself creating when dealing with collections, objects, and conditions, such as finding, filtering, plucking, and so much more. You will instantly see the power of Underscore.js by examining this example: var stooges = [{name: ‘moe’, age: 40}, {name: ‘larry’, age: 50}, {name: ‘curly’, age: 60}];   _.pluck(stooges, ‘name’);   => [“moe”, “larry”, “curly”] It is simply “plucking” out the “name” property from the array of objects. This is one of the several examples of what…

Read More

Using Sitefinity’s Dynamic LINQ to filter classifications

By | Sitefinity | No Comments

What is Dynamic Linq anyway? Dynamic LINQ has been around in the .NET space for a while. To know more about what Dynamic Linq is and how to use it in general (out of Sitefinity) please head to Scott Gu’s post. Now lets learn about Dynamic Linq in Sitefinity’s context. Sitefinity has implemented its own version of Dyanmic Linq under Telerik.Sitefinity.Data.Linq.Dynamic namespace. In this post we will see how you, the reader, can you Sitefinity’s Dynamic Linq and filter List Items based on classification. Why would I need Dynamic Linq? Dynamic Linq as Scott Hanselman describes makes custom Linq expressions…

Read More

Now in the Xamarin Marketplace: Falafel Bridge for TestComplete

By | Uncategorized | No Comments

    How sad! The TestComplete Bridge is no longer available. We are so excited to announce the release of Falafel Bridge for TestComplete, now available in the Xamarin Marketplace! The Falafel Bridge for TestComplete component allows Xamarin.Android apps to be white-box tested with SmartBear’s TestComplete 10 product. We’ve been adoring fans of TestComplete for twelve years now, and when we saw that TestComplete had Android testing capabilities, we were jumping with joy. Turns out however it sadly doesn’t work with Xamarin built android apps, and we wanted to fix that. Check out the demo below! Building your Xamarin.Android app…

Read More

The Four Deadly Sins of LINQ Data Access: Part 1–Overly Chatty Queries

By | News | No Comments

This is post 1 of 4 in the series “The Four Deadly Sins of LINQ” Introduction I love using LINQ to filter, transform, and aggregate collections. LINQ provides a very concise and expressive syntax that lets you do more with fewer lines of code, which in turn means generally higher productivity, reduced maintenance, and fewer bugs. However, all of these things are unconditionally true only regarding in-memory collections. When it comes to querying a relational DB, LINQ has a dark side: it’s almost too good at hiding what’s really happening. This could cause a naïve developer to write poor data…

Read More

LINQ From Scratch #2–Deferred Execution

By | Uncategorized | No Comments

A key, but often overlooked aspect of LINQ is that execution of query statements is deferred until you actually ask for the first item in the sequence. Consider this code, var list = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; var query = from num in list where num < 7 select num; // other code here foreach ( var num in query ) { Console.WriteLine(num); } C# applications typically execute from top to bottom.  You might, therefore, reasonably expect that the query would run right after the declaration of the list.  It…

Read More

Kendo UI ComboBox DropDownList Mashup

By | JavaScript, Kendo UI | One Comment

If you are using Kendo UI and need a widget for selecting an item from a list, you have a few options: DropDownList, ComboBox, and AutoComplete.  DropDownList requires you to select one of the items from the list, but the keyboard support is fairly cumbersome–the user needs to enter text quickly in order to jump to that item in the list. The ComboBox allows users to enter text as if it was a text box, but it doesn’t force them to match one of the values in the list–it allows custom text. What I’m looking for is a way to…

Read More

How to Read Toolbox Parameters for Sitefinity Widgets

By | Sitefinity | No Comments

When registering widgets into the Sitefinity toolbox, you’ll notice there is a parameters section. This allows you to add arbitrary key/value pairs of data. So how do you access these parameters? Through ToolboxConfig of course! //GET CONFIG using (var manager = Config.GetManager()) {     var config = manager.GetSection<ToolboxesConfig>();       //GET PAGE TOOLBOX     var pageControls = config.Toolboxes[“PageControls”];     var section = pageControls         .Sections         .Where<ToolboxSection>(tb => tb.Name == ToolboxesConfig.ContentToolboxSectionName)         .FirstOrDefault();       //GET CONTROL FROM TOOLBOX IF APPLICABLE     var controlType = typeof(ContentBlock); //THE TYPE OF WIDGET TO GET     var control = section.Tools.FirstOrDefault<ToolboxItem>(t => t.Name == controlType.Name);     if (control != null)     {         //PULL OUT PARAMETER FROM…

Read More

Kendo UI Web: Remote Views And Separate HTML Files

By | JavaScript | One Comment

When working with Kendo’s SPA implementation, you will soon realize that you can only create views out of existing elements on the page or feeding it raw HTML. What about remote views? Unfortunately, only Kendo UI Mobile gets to have remote views. In this post, I will show you how to extend Kendo UI Web’s kendo.View to give it remote view capabilities just like mobile! //EXTEND KENDO VIEW TO HANDLE REMOTE VIEWS var extendedView = kendo.View.extend({     promise: null,           init: function(element, options) {         var me = this;                   //DETERMINE IF ELEMENT IS URL FOR REMOTE RETRIEVAL         if (_.isString(element) && !/<[a-z][\s\S]*>/i.test(element)) {…

Read More

ASP.NET Forms Authentication in 4 Easy Steps

By | ASP.NET | 4 Comments

I often find that developers feel uncomfortable setting up Forms Authentication in their web applications. Maybe it’s because it’s often added for them in the various project templates provided by Visual Studio, or maybe it’s because it’s difficult to distinguish Forms Authentication from it’s buddy Membership Services, which is much larger and more complex. Whatever the reason, I thought I would create this post and do my small part to demystify the process of adding Forms Authentication to your project. For the purposes of demonstration, I started with an empty ASP.NET MVC5 project. Here are the steps: Enable forms authentication…

Read More

Duplicate Page Templates in Sitefinity

By | ASP.NET, C#, JavaScript, Sitefinity, Telerik, WebUI | One Comment

Background One of the missing features that people were asking for in Sitefinity is the ability to duplicate page templates. The “duplicate” feature is only available for pages and not for page templates. I was recently working on a project and that was one of their key requirements. In this column, I will show you how i was able to accomplish it. Solution The first part of the solution was creating a copy of an existing page template which is illustrated in the following code snippet: var manager = PageManager.GetManager();   var template = manager.GetTemplates().SingleOrDefault(t => t.Id == templateId);  …

Read More

Super Simple Spreadsheet Export from Kendo UI Grid

By | Uncategorized | No Comments

I was recently working on a way to download data displayed in a Kendo UI grid into a file for opening in Excel. Nothing fancy, just a way to grab a file that would open as a spreadsheet and let the user view the data.  Preferably something that could be done all client-side, and applied to all of the (many) Kendo grids on the site. Of course, I wasn’t the first person to need this – I found a great resource for converting the grid datasource into a .csv file, but what I also wanted was a easy way to…

Read More

Extend Native DOM Elements Using Web Components

By | Web | One Comment

Web developers love inheritance, don’t you? Who would have thought you can inherit something so basic as an HTML element and extend it! Now you can do this using the new Web Components specifications. As an example, how many times have you wanted to add captions to an image? Probably one of the most requested feature of the image. We can do this by extending it with our own custom element. Then, we use the native DOM element as normal, except add a new special attribute called “is”. This tells the browser that this “is” really a custom element that…

Read More