Experiences and Experiments in Programming

 Monday, February 18, 2013

If you are using Visual Studio 2012, you probably know that an update was made available toward the end of last year. Well they have done it again! The second update to Visual Studio 2012 is available now and this update has some terrific features.

There is no way to list them all but there are a few that I think will be usable very quickly.

There are some nice updates to the Visual Studio 2012 Page Inspector. The page inspector now supports live CSS updates. Also the Page Inspector allows you to map items that were added dynamically to a page using JavaScript back to the JavaScript code that added them. You can find out more about these features at http://blogs.msdn.com/b/webdev/archive/2012/12/14/css-auto-sync-and-javascript-selection-mapping-in-page-inspector.aspx.

Some of the things I am excited about are the ASP.NET editor enhancements.

  • You get some added syntax highlighting for things like CoffeScript, JsRender and others.
  • Even better, you get Intellisense for Knockout bindings!
  • If you use LESS (and you should), we know have first class support for editing LESS files. Previously in order to get LESS editor support, you had to install Mads Kristensen’s Web Essentials 2012 extension. This is a terrific extension with other enhancements besides LESS editor support. But it is sure nice to get editor support without having need for a third party tool. By the way, if you currently have the Web Essentials 2012 extension, you need to update it to the latest version prior to installing the Visual Studio Update 2.
  • If you have consumed any services that transmit data using JSON, you will love the “JSON to .NET class” support. You can paste (using Paste Special) any JSON data from the clipboard into a C# or VB.NET code file and Visual Studio will automatically generate .NET classes inferred from the JSON!

If you are one of the many developers using OData, ASP.NET Web API now provides support for OData endpoints that support both ATOM and JSON-light formats. There are also some other enhancements to ASP.NET Web API that you will find helpful!

If you use SignalR, then you will love the SignalR template support in this update! There are now templates for creating Hubs and Persistent Connections.

The ASP.NET team had released an out-of-cycle preview of a new library to support friendly urls in Web Forms. This is now included in this update. With this update, Web Forms supports friendly urls and mobile pages!  This is terrific news for developers of Web Forms!

ASP.NET MVC has its share of updates as well including two new interesting templates: A Facebook application template and the return of the Single Page Application template. For anyone who used the pre-release versions of Visual Studio 2012, you may remember the Single Page Application template as one of the available templates for ASP.NET MVC. The team decided to remove it before final release because it was just not ready. Well, it is back! This is a terrific addition to the available MVC templates! You can find out more about the Single Page Application template here.

There are more improvements in this update as well. If you want to find out more about some of the updates you can see Scott Guthrie’s announcement.

You can download the update here: Visual Studio 2012 Update 2.

Monday, February 18, 2013 12:58:55 PM (Central Standard Time, UTC-06:00)
 Friday, May 02, 2008

Anyone that builds or has built web applications, is familiar with the idea of writing some JavaScript code that will pop up a confirmation message to the user prior to performing a postback.

While I love JavaScript, I always thought the way this had to be done was a little messy.  An ASP.NET Button has an OnClick attribute, but this attribute's value is the server-side event that will be invoked upon a postback.  In order to invoke a client-side click handler in JavaScript, the attribute that must be set on the rendered HTML Input control is also OnClick.  Therefore, in order to accommodate both a client-side click event and a server-side click event, the client-side click handler must be added at runtime before the button is rendered.

In the code-behind, the following code would be used to add the client-side click handler:

!confirm('Are you sure you want to delete this item?'))
return false;"

In the markup, the button would then look like this:

<asp:Button id="btnDelete" onclick="btnDelete_Click"
runat="server" Text="Delete" /> ... </html>

Starting with .NET 2.0, there is an easier way to do this.  .NET 2.0 introduced the OnClientClick attribute.  Instead of having to add the "onclick" attribute to the button in the code-behind, you can use the OnClientClick attribute at design-time in markup.  The new button code would like this:

<asp:Button id="btnDelete" onclick="btnDelete_Click"
runat="server" Text="Delete" OnClientClick="return
confirm('Are you sure you want to delete this item?');"
/> ... </html>

Much cleaner to me.  And I like that it can be done at design-time!

Thursday, May 01, 2008 11:17:23 PM (Central Standard Time, UTC-06:00)
Who Am I - Todd Miranda
MVP Visual Developer - ASP/ASP.NET
On this page....
<November 2019>
Aggregate Me!
RSS 2.0 | Atom 1.0 | CDF
Contact me
Send mail to the author(s) E-mail