Prevent cutting or copying blank lines in Visual Studio

I hope you know that we are not required to select a line to cut or copy it in Visual Studio, you can just keep the caret in a line and press Ctrl + C or Ctrl + X and the text in the line will be copied to your clipboard and you can insert this line anywhere in your code by pressing Ctrl + V.

It will also copy a blank line, but people use Ctrl + X command to delete blank lines and some may find this as an issue as they didn’t intend to copy the blank line and also it will clear the previously copied item in the clipboard.

It is surprising as usual to find that Visual Studio team has thought out this and provided a setting which prevents the copying of blank lines, and Cut command will just delete the blank lines.

I found this when I recently bumped into the setting in Visual Studio, in Text Editor > All Languages called "Apply Cut or Copy commands to blank lines when there is no selection".


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

Do you know Notepad’s .LOG feature?

Thought of posting a simple feature of notepad that might be useful for many who log things in a file for various purposes, mostly this can be used for simple things that needs to be logged.

In Notepad, type ".LOG" (case sensitive) in first line of the file and save it, now close and reopen the file, current date and time will be inserted in the last line and you can type information and save.


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

The {not much utilized} Debug->Exceptions… window technique

The Debug-Exceptions… window is a useful tool that at times saves lot of time when debugging. Even though this exists (i think)from Visual Studio 2003, I Still find people struggle a bit with the situation I am going to explain next.  more...

Bookmark / Share