Select Page

Author: Omer

The Rumble Robot Is Here!

I’ve been thinking of about a fun technology project that I could work on with Dany (my 5 year old son) this summer. We’ve been talking about robots for a while and I’ve been looking for a good excuse to start playing around with Arduino – an open source electronics prototyping platform. So I was pretty excited to discover DinoFab’s tutorial on hacking a Rumble Robot toy and turning into your very own Arduino robot. I bought a used Rumble Robot Me-Fisto! from eBay for $15. Now I just need to get an Arduino micro-controller, a Ping ultrasonic sensor and a few other items and we’ll be all set for this project. More updates on this...

Read More

Using jQuery to Handle Checkboxes in ASP.NET MVC 3

Let’s say we have a simple to-do list application in ASP.NET MVC which displays a table of open tasks. And below that table, we display a list of completed tasks. The scenario is pretty straight forward – when a user clicks on an open task check box (to mark it complete) we need to update the database record for that task and then move it to the completed tasks list below. And vice versa – if a user changes their mind and unchecks the completed task, then we need to update the database record again and move that task back up to the open task table. There’s no submit button or form here – it’s going to be something we’ll handle dynamically with one click of a checkbox. Here’s part of the HTML generated by our Razor view. Each task has a unique ID e.g. ‘checkbox1’ based on the task ID in the database i.e. 1. I just added the ‘checkbox’ prefix to avoid confusion with lots of ‘vague’ numbered IDs all over the place in the HTML. XHTML <input id="checkbox1" name="checkbox1" type="checkbox" value="true" /> <input name="checkbox1" type="hidden" value="false" /> <a href="/item/Edit/1">Buy milk</a> <input id="checkbox2" name="checkbox2" type="checkbox" value="true" /> <input name="checkbox2" type="hidden" value="false" /> <a href="/item/Edit/2">Write status report</a> <input id="checkbox3" name="checkbox3" type="checkbox" value="true" /> <input name="checkbox3" type="hidden" value="false" /> <a href="/item/Edit/3">Pickup dry cleaning</a> <li class="completed"> <input id="checkbox4" checked="checked" name="checkbox4"...

Read More

Using jQuery with ASP.NET MVC 3

Using jQuery with ASP.NET MVC3 is pretty simple, especially now that it comes pre-installed with VS 2010. However, to set it up in a more scalable way with your project takes a little bit of work upfront but is definitely worth the extra effort in the long run. 1. Create a New Razor Helper Let’s start by creating a new Razor helper in the App_Code folder (you may need to create this folder if it doesn’t already exist in your project). Add a new Razor view called Content.cshtml and replace the entire contents of that file with the following helper code: ASP @using System.Web.Mvc; @helper Script(string scriptName, UrlHelper url) { <script src="@url.Content(" type="text/javascript"></script> } 12345 @using System.Web.Mvc; @helper Script(string scriptName, UrlHelper url) {    <script src="@url.Content(" type="text/javascript"></script>} 2. Add Script References to Layout Master Add the following code to the end of _layout.cshtml (before the closing body tag). ASP @Content.Script("jquery-1.5.1.min.js", Url) @Content.Script("jquery.unobtrusive-ajax.min.js", Url) @RenderSection("scripts", false) 123 @Content.Script("jquery-1.5.1.min.js", Url)@Content.Script("jquery.unobtrusive-ajax.min.js", Url)@RenderSection("scripts", false) 3. Adding New Script References Adding any new script references is now easy. We can just add them to _layout.cshtml. Just be sure to add those references before the RenderSection line to ensure that the scripts load in the correct order. ASP @Content.Script("jquery-1.5.1.min.js", Url) @Content.Script("jquery.unobtrusive-ajax.min.js", Url) @Content.Script("jquery-ui-1.8.11.min.js", Url) @Content.Script("modernizr-1.7.min.js", Url) @RenderSection("scripts", false) 12345 @Content.Script("jquery-1.5.1.min.js", Url)@Content.Script("jquery.unobtrusive-ajax.min.js", Url)@Content.Script("jquery-ui-1.8.11.min.js", Url)@Content.Script("modernizr-1.7.min.js", Url)@RenderSection("scripts", false) 4. Adding Script References For Specific Pages The RenderSection helper is used to...

Read More