Try jsFiddle.net, it’s cool

Whenever someone explains some issue they are facing by sending some snippets of code which contains HTML with Javascript or CSS. I use this cool tool called jsFiddle.net and paste the code they send me in the relevant boxes for HTML, Javascript & CSS in the site and work on the issue.

I do this even if I have the full file set of code in which the issue is present in one part of the code set, this helps much in issue isolation.

So checkout jsFiddle.net!

Bookmark / Share

A new feature in ASP.NET 4: Shorthand syntax for Html Encoding

So far if we need to HTML encode content that we throw out to the response stream we will use Server.HtmlEncode() method as below.

<%= Server.HtmlEncode(“Content”) %>

Now in ASP.NET 4 we have a new code syntax, which comes handy whenever you want to emit content with HTML encoding, the new syntax is <%: … %> the “=” character is replaced in this new syntax by the “:” character, as shown below.

<%: “Content” %>
Bookmark / Share

A little less cared ASP.NET’s NestedMasterPage

I have seen developers using user controls which will show and hide sections of site content based on the state of the web site. This is fine for some extent, you know when it becomes bad ? It becomes bad when only user controls are used even for site layout related stuff.

ASP.NET’s NestedMasterPage is a great thing, that, I should admit, I myself started using only recently earlier I was using other ways to display a set of pages in different layout in a website. NestedMasterPage is a master page which is based on another master page, you can have as many levels of nesting as you wish, as far as you don’t confuse yourself.

You create a NestedMasterPage based on which other normal ASP.NET pages will be created. You can have a Main master page in which a website’s most common UI elements are present and create NestedMasterPages for different areas of a site like subsections of a site like web interface for post Member login, etc.

Below is a simple depiction of what could be done with a NestedMasterPage in ASP.NET web forms.

12

Now, below images will give you some idea on how the layout of a site can be less messy if we use NestedMasterPages.

(click to enlarge)

ProdCat

(click to enlarge)

Checkout

Hope it’s understandable.

Bookmark / Share

Code Snippets in Visual Studio

This post gives introduces code snippets in Visual Studio, how you can use them and helps you find out the list of built-in code snippets for each language easily. Code snippets in Visual Studio are useful in reducing typing effort required to input code. Code Snippets help in several ways to simplify your work if you can remember to use them instead of typing the actual code. Code Snippets are present in Visual Studio from ver 2005.

To use code snippets, instead of typing the code you will type a shortcut, which actually is a word and press Tab key to insert the actual code to which the shortcut is linked with.

For example, to enter the below code..

for (int i = 0; i < length; i++)
{

}

You can type "for" and then press Tab, you will then get the code inserted into the code window as shown below..

2

3

Now you can see that “i” is highlighted, this means you can type a name for the loop variable, once you renamed it, you can press Tab to select “length” and rename it or specify what should be there, like, list.Count, etc. Once done, press enter to place the cursor inside the for loop braces.

As you can see, whenever you need to write a for loop you can just use this code snippet and save time, there are many code snippets like this which you can use.

Also, you can right click in the code editor and select Insert Snippet...(Ctrl+K, X) and choose the snippet you need from the list. You can also select lines of code and right click and select Surround With...(Ctrl+K, S) option to put the selected code into the snippet that you will insert, like, inside a try..catch block.

Code snippets are actually customizable as like most Visual Studio features. A code snippet is loaded from a “.snippet” file and the below image shows the location of the built-in C# code snippets. You can find snippets for VB & other languages in the language specific folder.

image

(C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Visual C#)

I will write a future post on how to create your own code snippet for frequently entered common code patterns in your project and how to distribute them within your team so that everyone can use them.

Bookmark / Share

New ASP.NET project gives a great webapp template in Visual Studio 2010

(This post is part of Visual Studio 2010 series)

When you create a new ASP.NET web application in Visual Studio 2010, you are getting a project which has a good set of features built into it for you to get started quickly. In previous versions of Visual Studio, when you create a new ASP.Net project, you just get one .aspx page with a web.config file.

New-ASP.NET-WebAppTemplate

 

(Visual Studio 2010’s solution explorer showing the contents of a just created Web Application project)

Visual Studio 2010’s new project template has the following..

  • Master page – with menu, login view control, etc., has good div based layout with nicely used css styles. Along with two files based on master page(Default.aspx & About.aspx).
  • Stylesheet - with styles for most elements your web pages will be designed with, that you can customize as you wish
  • Forms authentication enabled – provides you with .aspx pages which implements forms authentication, like, login, register new user and change password, with necessary configurations in web.config
  • Web.config file with Debug and Release versions, including sample Web.config transformations that you most probably need
  • Web.config readily configured for ASP.NET Membership, Roles & Profiles
  • jQuery library .js files included with three versions of .js files – one with Visual Studio intellisense support, a normal one and a minified one-which is used for production.

 

This new project template would help beginners and people who are yet to get good overview on how a typical ASP.NET web site would be written.

Bookmark / Share

A tip when working with QueryStrings..

We still use QueryStrings for many reasons even though we have other methods to deal with HTTP requests to web applications. And when working with QueryStrings, I hate to type Request.QueryString(“blah”), Request.QueryString(“blahblah”), Request.QueryString(“blahblahblah”), etc., again and again when I need to. This is more tiring if there are more number of QueryString items to deal with.

If you note, Request.QueryString is actually a NameValueCollection. So in suitable situations I would love to use a NameValueCollection object with a short name instead of Request.QueryString(“blah”) ;) as shown below. This saves time and provides a little better coding experience.

NameValueCollection q = Request.QueryString;

Response.Write("name" + q["name"]);
Response.Write("address1" + q["address1"]);
Response.Write("address2" + q["address2"]);
Response.Write("city" + q["city"]);
Response.Write("country" + q["country"]);
Bookmark / Share

Ctrl+Tab.. used like this could improve user experience..

Tabbed browsing..

Perfect feature parity ;)

Current version of all major browsers have Tabbed browsing feature. I’ve noted an issue in this tabbed browsing behavior since I started using a browser that had it. Before telling about the actual issue, I would like to remind you about a well known fantastic feature of Windows OS(I am not sure if any other OS already had it before Windows, Apple?). Any computer geek cannot live without it.

(For those of you who are not aware..you can open a new tab in latest browsers by pressing Ctrl+T and switch between each Tab using Ctrl+Tab, just keep this in mind..)

Alt+Tab... You know how useful it is, it helps to switch between different software applications running on your system easily, people who tend to use mouse less and keyboard more would love it, it’s their first great weapon.

But, have you noted a behaviour of Alt+Tab, if you press & hold Alt key and press Tab continuously you get a list of all running applications and you can choose from it. But if you just press Alt+Tab (and release Alt & Tab), Windows will take you to the previously focused application, and if you press Alt+Tab again(and release both keys) it will take you to the application from where you selected(focused) current application.

This functionality provides you an option to quickly swap between two applications. Especially it’s critical when you are referring content from one window and work in another window, like most developers, designers and any kind of data processing user would do.

So I would like to have the same kind of behaviour in Tab enabled browsers too, isn’t it? But in browsers if I use Ctrl+Tab in both the above mentioned ways I get the same result, it takes to the next tab sequentially. I don’t think providing Alt+Tab like behaviour would complicate the usability to beginners.

As most of you do, I will also spend lot of time doing comparisons and analyse various things, like, compare two mobile phones, gadgets, etc. In these times, I would like to swap as I do in Alt+Tab, it also becomes tedious for me to remember the tab position or locate the tab, if I open many of them as a result of my search and it ends up in a confusion and requires a higher level of concentration. This puts some stress on the user and might get a (slight)feeling similar to doing something in a work environment pressure and the user won’t enjoy the browsing experience ultimately, IMHO.

This issue exists in IE, FireFox, and Google Chrome, don’t know about anyother browsers, let’s see whether they think it should be changed. If you know if there is a browser that works as I wanted above, let me know, I think I will use it for specific browsing needs.

 

Bookmark / Share

Some new features of Visual Studio 2010 that can help your productivity right away

(This post is part of Visual Studio 2010 series)

I am playing with Visual Studio 2010 for some time now and just thought to sum up some of the new features of Visual Studio 2010 that could enhance your productivity right away after you start using it.   more...

Bookmark / Share

Visual Studio 2010 released :)

Finally, Visual Studio 2010 released today(April 12, 2010).

I saw few guys tweeting each other that they are so happy about Visual Studio 2010’s release and this video.

Do you wonder why they are that much happy? and are they maniacs?

I am happy too, reason is, it could help developers by providing cool features which aren’t available till now, which simplifies our job a considerable extent and gives time to apply thought where it is really needed.

 

Happy Programming ! (hopefully soon with Visual Studio 2010 :)

 

Don’t miss the video – When I Build You (The Visual Studio 2010 Song)....

 

Note: I couldn’t get the lyrics clearly and it says something about PHPers, but I think it’s just for fun and no offence intended to PHP developers :)

Bookmark / Share

Visual Studio 2010 new features series

This post will list all the posts related to Visual Studio 2010 in this blog, be it C# 4, visual basic 2010, .net framework 4 or Visual Studio 2010 IDE specific, you can find it here going forward. These posts will include tiny improvements to mega-features introduced in Visual Studio 2010.

 

 

As and when I find cool new features in Visual Studio 2010, I always hoped to write about them. I wish to have extreme time management capabilities, atleast from now… :)

 

(Note: All posts are as per things I said here, so if it suits any of those points, I will write :)

 

Bookmark / Share