Click here to Skip to main content
Click here to Skip to main content
Alternative Article

Simple but Interesting Features of VS2012

, 24 Feb 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
This is an alternative for "Simple but Interesting Features of VS2010 and C# 4.0"

Introduction

Usually we try and find distinctive function in the new release, but my article is to find simple yet useful features included in VS2012. 

Features for this Article

Image Thumbnail:   

In the solution explorer, we can add Images. The moment you bring your pointer on the image you can its thumbnail image. It make easy to identify the images. 

Page Inspector:   

When we have nested pages like if in MVC partial pages, in .net pages inside master page, it becomes very difficult to find with part of the code is responsible for the HTML being generated.  Here comes another useful feature if for a specific page u want to inspect, and then right click on the page. You can see the option "View in Page Inspector". 

The moment we choose Inspector, we can see the page in this format:

Whatever we select in the browser window, its HTML is shown below it and the page responsible for that HTML is shown on the right. Earlier we use to run the code, then use tools like firebug to inspect it and for any change we have to stop the solution, apply the changes and run again to see its reflection. But with this option we can apply changes and see its reflections. For this feature we require IE9.

Color Picker: 

A feature which most of the developers need, as its difficult for them to remember the color name, if they get the color picker it’s easy to set the color. VS2012 provided inbuilt color picker for CSS. Just type # before the color and you can see the color picker. Select any color of your choice and the code gets added. 

IIS Express:

VS2012 has IIS express as its default server.  IIS Express is a lightweight, self-contained version of IIS that contains all the core capabilities of the IIS web server role. In Visual Studio 2010 SP1, IIS Express was available as an option that you had to explicitly configure. IIS express following features

  • It does not run as a service or require administrator user rights in order to perform most tasks.
  • IIS Express works well with ASP.NET and PHP applications.
  • Multiple users of IIS Express can work independently on the same computer.

For more information visit IIS Express Overview

Tag completion when renaming tags: 

HTML Editor has a beautiful facility while renaming a tag. For example if you have added a <div id="div1">Name</div>. After writing you felt instead of div you must take a span, the moment to change the div word to span automatically the closing tag will be changed to </span>. This will help the developers from getting the UI issues because of the closing tag missing.

Extract to user control:  

When we have large web page, we can pick some control from the source view and create a user control for the same. This helps in improving the readability of the page.

Select the controls--> Right click your mouse and select Extract to User Controlà Give name to your control and the entire line of code will be replaced by one single control. 

Event Handler:  

The moment we add any Asp control and wants to manage its event handler, VS2012 IntelliSense displays <Create New Event>, which creates an event handler in the code view with the right signature.



AntiXSS Library: 

AntiXSS Library which was part of .net 4.0 but was external, now it’s being included in 4.5. If your page requires HTML-formatting then the page becomes insure and inorder to protect your page from cross-site scripting attacks you need to include AntiXss library.

The AntiXSS library in 4.5 include following external features:

  • HtmlEncode, HtmlFormUrlEncode, and HtmlAttributeEncode
  • XmlAttributeEncode and XmlEncode 
  • UrlEncode and UrlPathEncode (new)
  • CssEncode

Multiple browser support: 

All the browser’s installed in your system can be used to test the application. It becomes easy if your application is supporting multiple browsers. You can see the UI in all browsers supported. 

Round Tripping

A very important feature, this is required when we are upgrading from older version to new version say from VS2010 to VS2012 and you want your project should work in both VS2010 and VS2012. Round Tripping helps to work with existing Visual Studio 2010 projects, it’s easy to upgrade project to VS2012, and we can use both VS2012 and VS2010 at the same time. 

Summary

I have created a sample application using all the above mentioned features. It has become really very interesting when trying to go deep in these features and there are many more to explore. I have studied other features related to the data controls, validations. Will surely try to include them in my next extension of the article.

While writing the article, i have refered following site What's New in ASP.NET 4.5 and Visual Studio 2012

Continuation

Let's start with some more interesting features.

Background 

In my previous part, I tried to figure most and basic functions, yet I felt are very useful. In this article I am trying to cover some simple and some interesting features

JavaScript Matching Braces

If we are writing any function in JavaScript which has too many opening and closing braces, and if we miss one of the closing braces, then it becomes very difficult to identify which opening braces closing is missing. With .NET 4.5 we can select the braces and it tells its closing braces, so it becomes easy to identify the nesting structure. 

JavaScript Code outlining:  

Till the previous versions outline was supported only for .cs or .aspx file, now outlining regions are available in JavaScript too. It helps us to collapse the file or function which is currently not the part of our focus. 

Request Validation: 

Cross scripting is a security threat, when a developer is allowing script and HTML tags. But in many situations we need our page to support HTML and scripts. In such situations .NET 4.5 provides us with two features

Deferred "lazy" request validation- for selective part  Access to unvalidated request data

Whenever a request is made, it’s always validated for the complete data and if it is turned off then it is not validated at all. Using Lazy request validation only required data will be validated. To enable lazy request validation set "requestValidationMode" attribute to "4.5" in "httpRuntime" element in web.config.

How this will work, let’s take a simple example if I wish to validate data when a particular button is clicked, in such scenario, I don’t want when the page load the request should be validated, it should be validated whenever the button is clicked. This was not possible with the earlier versions of .Net, but now lazy request validation will do the same in .NET 4.5.

 It can be used like:

  • Request.Unvalidated.Cookies["Name"]  
  • Request.Unvalidated.QueryString["VarName"] 
  • Request.Unvalidated.Form["Value"]   

Example: I have added two asp textboxes and one asp button. I have set the requestvalidationmode to 4.5. The moment I tried to enter the string with HTML tag. I get the error "Potential dangerous request………" 

 

This is my code

   

The moment I replace the asp textbox server control with simple HTML control and click the submit button. It works fine. The structure looks like this: 

  Now lets access the same from the code:

Again I get the same error "Potential dangerous request………" But again I try to access the page by a slight change in the code and it works fine.

Now coming back to asp textboxes that means server controls, .Net tries to use the posted data to maintain the view state, so will get the error. In order to avoid this .net has introduced "ValidateRequestMode" feature. We can set as "disabled" for the textbox for which we don’t want the server to request validation.

 

After adding ValidateRequestMode, it works fine. This feature is important, as earlier we use to set validation request to false at the page level and the entire page becomes open for cross scripting. But with this feature only a part is open and remaining page is secure from XXS attacks.

CSS Editor:Hierarchy Indentation:  

The moment we create hierarchy with CSS it automatically gets indented and we can see the inheritance.  Hierarchical indentation is enabled by default, butif user wishes can even disable it. To turn off select Tools->Option->Text Editor->CSS-> Formatting  

In the figure below, you can see 3 level hierarchy, first level is the  div, then next is anchor inside div and third level is hover on anchor inside div.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Anuja Pawar Indore
Technical Lead Diaspark
India India
I have keen interest in learning new things, exploring more on a topic and being more versatile
Follow on   Twitter

Comments and Discussions

 
QuestionNice one at all PinmemberUmairAslam18-Nov-13 19:35 
AnswerRe: Nice one at all PinmemberAnuja Pawar Indore18-Nov-13 20:50 
QuestionThe Programmer Newspaper PinmemberMarla Sukesh6-Sep-13 8:04 
AnswerRe: The Programmer Newspaper PinmemberAnuja Pawar Indore9-Sep-13 20:33 
QuestionThanks for sharing PinmemberJagz W14-Jun-13 2:42 
AnswerRe: Thanks for sharing PinmemberAnuja Pawar Indore14-Jun-13 22:03 
Generalnice job Pinmemberpinguit4-Mar-13 14:36 
GeneralRe: nice job PinmemberAnuja Pawar Indore4-Mar-13 22:18 
QuestionNot bad PinmemberBryan Schuler26-Feb-13 7:19 
AnswerRe: Not bad PinmemberAnuja Pawar Indore26-Feb-13 10:30 
QuestionNice Article Pinmemberkanjolia gopal25-Feb-13 22:25 
AnswerRe: Nice Article PinmemberAnuja Pawar Indore25-Feb-13 22:41 
QuestionNice Article PinmemberNikhil Khandelwal (MCTS, Web 4.0)16-Dec-12 20:00 
AnswerRe: Nice Article PinmemberAnuja Pawar Indore16-Dec-12 20:16 
QuestionNice Article..... Pinmembersachin_ kulkarni25-Oct-12 1:42 
AnswerRe: Nice Article..... PinmemberAnuja Pawar Indore25-Oct-12 3:11 
QuestionVery Interesting PinmemberAshishChaudha18-Oct-12 19:17 
AnswerRe: Very Interesting PinmemberAnuja Pawar Indore18-Oct-12 19:33 
QuestionGood work PinmemberSunny Setia17-Oct-12 1:14 
AnswerRe: Good work PinmemberAnuja Pawar Indore17-Oct-12 1:27 
GeneralMy vote 5 PinmemberNitin Sawant15-Oct-12 22:05 
GeneralRe: My vote 5 PinmemberAnuja Pawar Indore15-Oct-12 22:17 
QuestionGoood PinmemberLakxman15-Oct-12 20:19 
AnswerRe: Goood PinmemberAnuja Pawar Indore15-Oct-12 20:25 
Questioncomment Pinmemberankitpatel101015-Oct-12 19:51 
AnswerRe: comment PinmemberAnuja Pawar Indore15-Oct-12 20:03 
GeneralNice Article PinmemberSujit Bhujbal15-Oct-12 19:10 
GeneralRe: Nice Article PinmemberAnuja Pawar Indore15-Oct-12 20:02 
GeneralNice start up Pinmembersathish0402198415-Oct-12 17:11 
GeneralRe: Nice start up PinmemberAnuja Pawar Indore15-Oct-12 20:00 
GeneralRe: Nice start up Pinmemberafzal.gujrat16-Oct-12 1:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.141022.1 | Last Updated 25 Feb 2013
Article Copyright 2012 by Anuja Pawar Indore
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid