Home / ASP.NET Weblogs

Latest Microsoft Blogs

Browse by Tags

Related Posts

  • A C# helper to read and write XML from and to objects

    I really like jQuery’s pattern of attribute getters and setters. They are fluent and work really well with HTML and XML DOMs. If you specify a value in addition to the name, it’s setting, otherwise it’s getting. In C#, we have an OK API for XML, XElement, but it’s not as easy to use as jQuery’s attr methods. It is also missing the flexibility of Javascript with regards to parameter types. To recreate the simplicity of attr in C#, I built a set of extension methods for the most common simple types: var el = new XElement("node"); el.Attr("foo", "bar") .Attr("baz", 42) .Attr("really", true); var answer = el.Attr("baz"); The element built by this code looks like this: <node foo="bar"...


  • ‘Paste JSON As Classes’ in ASP.NET and Web Tools 2012.2 RC

    ‘Paste JSON As Classes’ is a cool feature in ASP.NET and Web Tools 2012.2 RC. This feature will help you generate strongly typed classes in C# or VB.NET from valid JSON text. With ASP.NET and Web Tools 2012.2 RC installed, you will see new menu option like below for C# and VB.NET Website and Web Application projects only. This new menu option will be enabled for .cs and .vb file extensions inside these projects: JSON to C#/VB.NET class conversion To use this feature, just copy sample JSON text and “Paste JSON As Classes” inside .vb or .cs file. This feature uses Newtonsoft JSON parser to parse JSON text from clipboard. Once Newtonsoft JSON parser validates the clipboard data as valid JSON, then it will be converted into...


  • Namespaces are obsolete

    To those of us who have been around for a while, namespaces have been part of the landscape. One could even say that they have been defining the large-scale of the landscape in question. However, something happened fairly recently that I think makes this venerable structure obsolete. Before I explain this development and why it’s a superior concept to namespaces, let me recapitulate what namespaces are and why they’ve been so good to us over the years… Namespaces are used for a few different things: Scope : a namespace delimits the portion of code where a name (for a class, sub-namespace, etc.) has the specified meaning. Namespaces are usually the highest-level scoping structures in a software package. Collision prevention : name collisions...


  • Code is not the best way to draw

    It should be quite obvious: drawing requires constant visual feedback. Why is it then that we still draw with code in so many situations? Of course it’s because the low-level APIs always come first, and design tools are built after and on top of those. Existing design tools also don’t typically include complex UI elements such as buttons. When we launched our Touch Display module for Netduino Go! , we naturally built APIs that made it easy to draw on the screen from code, but very soon, we felt the limitations and tedium of drawing in code. In particular, any modification requires a modification of the code, followed by compilation and deployment. When trying to set-up buttons at pixel precision, the process is not optimal. On the other hand...


  • SignalR 0.5.1 Released

    Here comes another exciting release of SignalR . This release has some new features that you can take advantage of as well as a few bug fixes. Let’s go over the big changes for this release. Windows 8 Client support With the Windows 8 Release Preview, we’ve finally added a new client to support “.NET for Metro Style Apps” and also made some fixes so that SignalR’s JavaScript client works with WinJS. WebSocket Support Previously, websocket support required a separate package, now it’s built into SignalR. The ASP.NET host is the only one that supports this and that’s only when running an application targeting .NET 4.5 on IIS8. Improved Cross Domain Support We introduced cross domain support for SignalR in 0.5. In this release we’ve improved that...


  • Etching sketches with a Netduino Go

    Netduino Go is designed for much more than toy projects, but one has to recognize that toy projects are fun and also great learning experiences. Today, I want to take you through the process of reproducing the behavior of a famous toy that you will surely recognize. That toy, that has helped many of us realize what poor motor skills we possess, has two knobs that control the horizontal and vertical coordinates of a pen that draws into the dust on the back of a simple screen. It’s a great mechanical device that is part of western culture. Our version will use two potentiometers , a 320x240 LCD display , a button to erase the screen, and of course a Netduino Go . The hardware setup looks like the following: We connected the button to port 2 (but...


  • Electronics for developers with Netduino Go

    Wouldn’t it be great if you could build your own stuff? Microcontrollers let you do that, but they usually require dealing with a lot of complexity and unknowns. If you’re a software developer, chances are you don’t really know how to use a capacitor, or how a transistor works, even though it is at the heart of all computers. Well there is a way now to develop awesome hardware projects without knowledge of electronics, just by connecting modules together. Netduino Go is a platform that allows for that without constraining the types of projects you can build. Today the number of available modules is still limited (the platform was released only last Wednesday), but it is expected to grow fast. In this post, I’ll introduce you to the platform...


  • PIX-6T4, the DIY console, has an Orchard site

    If you're a regular reader of this blog, you may have noticed the electronics posts lately. With my friend Fabien , we've been building a little handheld console from readily available parts. It's also programmable in C#, using a library that we built . It's great fun really. Our plan is to build a kit and a book out of it, to help people learn the basics of digital electronics and C# programming. We've built a site for the project over a few nights last week, using Orchard and hosting on Azure . I thought I'd throw in a little return on experience and talk about the modules we used. The site can be found here: http://www.pix6t4.com The first thing I did to build the site was to build the theme. I started from the built...


  • Dealing with singular plural phrasing

    This is an age old problem and one that’s probably been solved countless times before, but I’m going to write about it anyways. Say you’re writing code like this: < p > You have the following themes: </ p > < ul > @ foreach(var theme in Model) { < li > @ theme.Id </ li > } </ ul > The natural inclination for the lazy developer is to leave enough alone and stop there. It’s good enough, right? Right? Sure, when the value of Model.Count is zero or larger than one. But when it is exactly one, the phrase is incorrect English as it should be singular “You have the following theme”. I must fight my natural inclination here! On the NuGet team, we have a rallying cry intended to inspire us to strive for better, “Apple...


  • So what are zones really?

    There is a (not so) particular kind of shape in Orchard: zones. Functionally, zones are places where other shapes can render. There are top-level zones, the ones defined on Layout, where widgets typically go, and there are local zones that can be defined anywhere. These local zones are what you target in placement.info . Creating a zone is easy because it really is just an empty shape. Most themes include a helper for it: Func<dynamic, dynamic> Zone = x => Display(x); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd...


Page 1 of 7 (65 items) 1 2 3 4 5 Next > ... Last »

Archives