Programming

ByTrent Jones

Garage Door Opener with Automation Integration

This project has been years in the making. I first started with a netduino plus 2 and had things functioning but quickly lost the connection and the requirement to unplug and plug back into development computer was cumbersome. Then along came the Spark Core. This device has build in wifi and you can use online code editor to publish directly to the device after you establish the core on your wifi.

Using an old garage door opener remote, i can locate the device anywhere in my garage that has power. In addition i have a magnetic switch hooked up to tell if the door is open or closed.
The Core exposes internet-addressable functions that can instruct the device to run an operation (open/close and isOpen). This in turn is hooked up as custom functions on my Vera Lite home automation controller.

Parts List:
Spark Core
https://www.particle.io/

Magnetic Switch
http://www.amazon.com/uxcell%C2%AE-Window-Sensor-Magnetic-Switch/dp/B00HR8CT8E/ref=sr_1_2?ie=UTF8&qid=1465224593&sr=8-2&keywords=reed+switch+alarm

Old Remote Garage Door Opener

Various Resistors

5v Power Supply

ByTrent Jones

ASP.NET 4.0 and Control IDs

In .NET 4.0 there is a new option when adding controls to a page or user control: ClientIDMode.  This property offers you four choices: Legacy, Static, Predictable, Inherit.  Previously it was almost impossible to find the id of a control in a normal matter such as jQuery.  Using

Choosing Legacy will continue to issue an ID in the same manner they were generated in previous version of ASP.NET, by concatenating the ID values of each parent naming container with the ID of the control.  Setting the property to Static will use the exact value of the ID property of the server control.  Predictable is used for controls that are data-bound controls such as repeater and also makes use of a ClientIDRowSuffix property.  Using Inherit makes the control ID property use the setting of its parent control.

In the example below, two lists are created inside the ContentPlaceHolder of a page using the same DataSource. The first is using the default and the second uses the new property with Static set as the value.

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:XmlDataSource ID="LinkData" runat="server" XPath="Colors/Color">
        <Data>
            <Colors>
                <Color Name="Red"/>
                <Color Name="Blue"/>
                <Color Name="Yellow"/>
                <Color Name="Green" />
            </Colors>
        </Data>
    </asp:XmlDataSource>
    <asp:BulletedList ID="uxList" DataSourceID="LinkData" runat="server" DataTextField="Name" />
    <asp:BulletedList ID="uxListStatic" ClientIDMode="Static" DataSourceID="LinkData" runat="server" DataTextField="Name" />

    <script type="text/javascript">
        $(function() {
            $("#uxList").append("<li>Red</li>");
            $("#uxListStatic").append("<li>Brown</li>");
        });
    </script>
</asp:Content>

Here is the output of the page in HTML

<div>
    <ul id="ctl00_ContentPlaceHolder1_uxList">
        <li>Red</li><li>Blue</li><li>Yellow</li><li>Green</li>
    </ul>
    <ul id="uxListStatic">
        <li>Red</li><li>Blue</li><li>Yellow</li><li>Green</li>
    </ul>

    <script type="text/javascript">
    $(function() {
        $("#uxListStatic").append("<li>Brown</li>");
    });
    </script>
</div>

And the corresponding view in the browser

•    Red
•    Blue
•    Yellow
•    Green

•    Red
•    Blue
•    Yellow
•    Green
•    Brown

Because of the generated tag on the first list jQuery can’t find the control to append to.

ByTrent Jones

Auto-Start ASP.NET Applications

Scott Guthrie has an article up on his website discussing the new auto-start feature of web applications that will be available in IIS7.5 with ASP.NET 4.0.  I just learned about this last week at the Southern Fried Road Show.

http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx

ByTrent Jones

960 Grid System

I am going to try and enlist the 960 Grid System on a website I am working on.

“The 960 Grid System is an effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.”

http://960.gs/

ByTrent Jones

monoTouch development kit now available for iPHone

monoTouch enables applications developed in any .net language to run on the iPhone. Significantly, monoTouch provides .net bindings to native API, allowing application developers will have access to iPhone specific functionality from within their .net applications. monoTouch integrates with both the free MonoDevelop IDE as well as Apple’s XCode toolkit

http://www.downloadsquad.com/2009/09/14/monotouch-net-development-kit-now-available-for-iphone/

ByTrent Jones

MVC, WebForms, ZeroForms

Interesting article comparing MVC vs. WebForms and a third option known as ZeroForm.

http://madskristensen.net/post/WebForms-or-MVC-What-about-the-third-option.aspx

ByTrent Jones

Entity Framework Code Only option

.NET 4.0 and VS 2010 introduce a new feature for the Entity Framework called model first.  In addition, you will now be able to have a code only model. Written with POCOs and a simple class derived from ObjectContext and you are on the way…

http://blogs.msdn.com/efdesign/archive/2009/06/10/code-only.aspx

ByTrent Jones

Using Stored Procedures with Entity Framework

Yesterday i was attempting to use a stored procedure with the Entity Framework through the “function import” features and couldn’t get the auto-gen feature to expose the function on the Context.  The stored procedure was returning a scalar value which at this point doesn’t seem to be supported through auto-gen.  Choosing an Entity, however works fine. Further digging this morning led me to this article on the ADO.NET team blog explaining the issues with return types and stored procedures in Entity Framework.  The article also links to another great article showing how to return custom types two ways:  one way through the entity framework itself, the other through the use of extension methods.

ADO.NET Entity Framework Extensions

ByTrent Jones

Using T4 to Generate Stored Procs for Entity Framework

T4 code generation has been on my short list of things to look into but keeps getting put off as i navigate down some other endless path.  Meanwhile, I found a nice article on using T4 to generate stored procs for CRUD operations for the Entity Framework.

Entity Framework Stored Procedure Generation

Thanks David.