Aashish Gupta’s Blog

December 7, 2008

Visual Studio 2008 Tips & Tricks for Developers:- This includes some shortcuts and some hidden features in Visual Studio 2008 which will increase your productivity

Filed under: Uncategorized — ash143gupta @ 6:38 pm
  1. Working in Full Screen Mode in Visual Studio
    1. Alt+Shift+Enter is the shortcut to enter to fullscreen mode in Visual Studio
    2. Its sometimes really helpful and more appealing for developers to work in full screen mode
  2. Editing
    1. For Copying a line in the IDE just go to the start of the line and press Ctrl+C,there is no need to select anything
    2. For Pasting a line just go to the start of the line and just press Ctrl+V
    3. For Deleting  a line just go to the start of the line and press Ctrl+X,  this is not actually delete but its similar to cut if you do Ctrl+X on current line and go to some other place in your code and do Ctrl+V then it will paste the same line there.
    1. Expanding and Collapsing the code units
      1. This nice little shortcuts has saved me a lot of time.Whenever i am working on a large piece of code i always get confused and make some changes in other Method or property because they were looking similar.
      2. But now with this shortcut i collapse one method as soon as it is finished.
      3. The shortcut is Ctrl+M+M.
      4. Just go to the beginning or end of the method or property or any code block and hit the shortcut it will expand or collapse the code block comparing to its present state.
    2. Automatic Text Indentation and Formatting
      1. This shortcut helps me to write beautiful and decorative code which is easy to understand by any person.
      2. Shortcut is just press Ctrl+K+D.
      3. This works not only in C# and VB code behind but it works well in aspx pages.
      4. If you want to just format the selected piece  of code then just press Ctrl+K+F
    3. Automatically adding Namespaces
      1. Use the Ctrl+. (Remember this is Ctrl+[period] if you get confused) shortcut key to automatically get intellisense for probable namespaces.
      2. Just press enter to include the required namespace.
      3. There are much cooler tricks when using a refactor like Resharper.I will discuss those tricks later this month in one of my posts.
    4. Commenting And Uncommenting The Code
      1. This trick saved me a lot of time.
      2. Just select the code to be commented and press Ctrl+K+C,this will comment your code block.
      3. For uncommenting the code just press Ctrl+K+U,this will uncomment the code block.
    5. Automatically generating properties
      1. Generating dummy getter and setters or properties is also a pain in big projects.
      2. Although i would recommend you some refactors like Resharper which can do it for you or some code generators like Code Smith and also give a try to inbuilt on in Visual Studio 2008 called T4 or Text Template Transformation Toolkit.
      3. But if you don’t have such a mass volume project and just don’t want to write your getter and setters then just type this prop + TAB+TAB
      4. Remember you don’t have to type all of this but you only type prop and then press TAB two times for VS2008 to automatically generate the property for you now you can change the name and any other thing by navigating and just pressing TABS.
    6. Increasing and decreasing the indentation
      1. Select the code block for which you want to increase the indentation and after selecting just press TAB,this will increase the indentation.
      2. To decrease the indentation just select the required code block and then press SHIFT + TAB,this will decrease the indentation of the selected code block.
    7. Selecting a single word then line and then other lines within that block and then…….
      1. This is also a cool trick if you are in middle of something and want to do something on either the word you are on or the entire code block, or entire method, or entire class then just go on pressing Ctrl+W,it will start selecting for you starting from the current word.
      2. After selecting the desired code block you can perform any operation on that code block.
    8. Build & Debug Shortcuts and tricks
      1. To build  a solution just press Ctrl+Shift+B
      2. To start debugging just press F5
      3. To stop debugging just press Shift+F5
    9. Find Options
      1. You are already familiar with Ctrl+F option to find something either in current documents or all open documents or entire project  or entire solution,but another find option is Ctrl+Shift+F, this trick is helpful when you want all your results to be listed in a find window rather then to navigate one by one in every file where the searched string exists.
    10. Selecting Source Control Plugin
      1. If you are working in a team you probably will be using a source control there are many options to choose SVN,Visual SVN,TeamFoundationServer,Source Vault and Source Fortress and many others.
      2. But when selecting a client you have to mention it in Source Cotrol Plugin Selection as shown below

    11. I want solution for every project which i create
      1. If you want a solution for every project which you create then you have to enable this as shown below

    I would have really forgotten many things which could be added in this list.I will update this list regularly  as I encounter any new thing,so stay tuned for more

    Also I would be doing an extensive post on Resharper 4.0,the most sharpest refactoring tool available out there its not just a refactor but a way beyond that

    Believe me i use it in my day to day coding and it makes development process 100K faster.

    Happy Programming!!!!

    November 29, 2008

    Blogger Tips And Tricks:- Opening each link from your new Blogger blog in a new window

    Filed under: Uncategorized — ash143gupta @ 5:37 am

    If you want your visitors to stay for long on your blog and they should not navigate from your blog even if they are clicking any external links from your blog then this small trick is what you all need.

    Opening the links in a new window will allow your visitors to return to your blog once they have read the information in the external link which you provided on your blog.Sometimes readers just simply forget your blogs name while they navigate through and then just don’t care to come back again.

    So to provide an easy hand to your visitors this trick can be of help.

    Workaround

    1. Just sign in to your blogger and navigate to Layouts Section.
    2. Under layouts just click Edit HTML link.
    3. Remeber to backup your existing template now so that you can rollback if you don’t like the changes.

    4.Now just search for the </head> section in your blogger template.Remember to edit this template in firefox because it will allow you to search within the template rest all browsers which i have tested only search on the visible content on the page.

    5.After you find </head>.Just above it enter this exactly the same way it is given below.

    <base target=’ &quot;_blank&quot;’/>

    Here in my blog the html tags will be replaced by their tags and symbols so i have provide the image below on how you should add this so kindly do it the same way.

    Remeber this is tested only for new blogger.I have not tested this myself for old blogger.

    That’s all now save the template and see the changes now your every link will open up in a new window not in the same window in which  your blog was opened.

    If you have any doubts then do leave a comment.

    November 28, 2008

    Google Calendar Sync for Windows Server 2003:-Install Google Calendar Sync on your Windows Server 2003 Systems

    Filed under: Uncategorized — ash143gupta @ 4:04 am

    If you use Microsoft Outlook as a Desktop Client and want to synchronize your Google Calendar then you need to download and install Google Calendar Sync which can be downloaded here.

    http://dl.google.com/googlecalendarsync/GoogleCalendarSync_Installer.exe

    How to install this on Windows XP and Vista can be found here on this link

    http://www.google.com/support/calendar/bin/answer.py?answer=89955

    But if you are running Windows Server 2003 then this installer will fail and give an error stating that this can only be installed on Windows XP and Windows Vista operating Systems.

    Workaround

    1. So the solution of this problem is just download a tool by microsoft called Application Verifier.
    2. Install this tool and just go to File ->Add Application.
    3. Now add the Google Calendar Sync.exe to this and just fool the installer to think that it is going to install on Windows XP system.
    4. How to do this is explained here in this article remember it shows the workaround for Photoshop CS3 but you have to open the Google calendar Sync file.

    http://smallworkarounds.blogspot.com/2008/09/installing-photoshop-cs3-on-windows.html

    Just copy the below as same given in the above article -   

    Major Version — 5

    Minor Version—- 1

    Build Number —  2600

    Service Pack Major — 2

    Service Pack Minor — 1

    Now just click save and run the Google Calendar Sync.exe

    Now it will just work fine.

    I have not tested it for Windows Server 2008.Anyone who tested this trick please do leave a comment telling that is it working or not in WS2008.

    November 22, 2008

    Adding LinkedIn Button To Blogger or WordPress or any other Blog

    Filed under: Blog Publishing — ash143gupta @ 9:27 am

    Today i was trying to add a “LinkedIn” to my linked in profile button on Blogger.But it was not so easy.

    You can directly embed the HTML and get the linked in image link if you want but for me it didn’t workde.Then i came to know that the linked in people themselves provide custom buttons that you can add anywhere either to your blog or your websites.

    But these custom button service is rather hidden ie not visible at the first sight.So i thought that it would be helpful if i share this post with you all.

    Below i have given detailed description with images on how to add this linked in button to your blog.

    Steps:-

    1. Just go to http://www.linkedin.com/

    2.Sign into your profile

      3.Goto public profile and click the edit button next to your public profile
                        4.Click on promote your profile add custom buttons link

                            5. Now you can see a lot of buttons and their respective code which you can directly paste into your blog.

                            Outlook 2007 Signatures:- Using custon HTML and styles in Signatures in Outlook 2007

                            Filed under: Outlook 2007 — Tags: — ash143gupta @ 9:17 am

                            Outlook 2007 does not give the facility to put the custom HTML and styling in Signatures under the signatures box.

                            As you can see that by default when you edit your signatures you only have Delete New Save Rename Options.

                            And also a few options to insert image and some hyperlink but no support for any kind of custom editing of HTML and styles.

                            So what to do if you want to enter some custom HTML and do some styling to your signatures while using Outlook 2007.

                            Here is the workaround.

                            WorkAround

                            Just Navigate to your “C:\Documents and Settings\(your_username)\Application Data\Microsoft\Signatures”.

                            Here Search for the htm file which will generally be starting with you Name.

                            Open this file in Notepad , Notepad++ and add whatever custom content you want to add.

                            Click Save and you are done.

                            Open your Outlook Signatures Box to see that changes made by you are reflected or not.

                            Send a mail to your another account to check whether your custom signatures are working or not.

                            Visual Studio is missing default templates

                            Filed under: Visual Studio — Tags: — ash143gupta @ 8:48 am

                            If your Visual Studio either VS2005 or VS2008 is missing some default tempates, or whenever you want to add any new item and click add new item you are surprise to find that either your add new WebForm is missing or any other similar item is missing from the add new item list then your templates defaults are corrupted due to some reasons or latest updates or patches or any other software which you have recently installed.

                            Workaround

                            So the workaround to this problem is:-

                            1. Just go to the Visual Studio command prompt.
                            2. Close all opened instances of Visual Studio
                            3. Run this command devenv/installvstemplates on Visual Studio Command Prompt.
                            4. And thats it all your templates will be set to defaults.

                            November 18, 2008

                            Want to transfer your post:- From Blogger to Blogger,Blogger to WordPress,LiveJournal to Blogger,Blogger To Windows Live Spaces all in all almost every blog.

                            Filed under: Uncategorized — ash143gupta @ 8:56 pm

                            If you want to transfer your posts from one blogging platform to another and are facing problems , then Paul Cooley has a very good application which he calls “Blog2Blog” which can do this for you very easily.

                            I have myself tested it for my blogger to blogger transfer and it works just fine.

                            Also in blogger i was unable to find a safe way to transfer all the posts or selected posts to another blogger account.

                            But with this tool you can achieve the same easily.

                            You can download the tool from here:-

                            http://www.paulcooley.com/linuxlore_blogstorage/apps/blog2blog/blog2blog-2.4.0.2.zip

                            Instructions for using the tool

                            • Just Click the setup.exe and install the application.
                            • Once installed it will open up an interface like this

                            • In select source select the blogging platform from which you want to import the posts.
                            • Enter your username and password source-URL ex. http://smallworkarounds.blogspot.com.
                            • Then for the source-API-URL especially in blogger if you are using old blogger then the defaults which will be coming will work.
                            • But if you are on new blogger then you have to open your blog on the home page and do the view source.
                            • In view source you can locate and entry which says “service.post” and there will be a link after that as shown below.

                            • Just copy and paste that link to the source-API-URL and this is it your source is set up.
                            • Remember that this trick is for new blogger only.
                            • Once completed with all the above things just press fetch.

                             

                            • After fetching is completed just repeat the same steps for your destination blog also.
                            • Once you are done with your destination blog then just click publish.
                            • And thats all you will see all the posts being published to your new blog.

                            Thanks! for this great tool by “Paul Cooley”

                            http://linuxlore.blogspot.com/2007/09/livejournal-to-blogger-or-blogger-to.html

                            November 17, 2008

                            C#—-When to use As Keyword in C#

                            Filed under: Uncategorized — ash143gupta @ 8:47 pm
                            1. As keyword is a hidden treasure in C# which most of us don’t use in our day today programming.
                            2. As keyword is used for the comparison of compatible types
                            3. Its general syntax is expression as type where expression is also a reference type and type is also a reference type.
                            4. Whenever there is nothing in the object instead of complaining to user or throwing an exception it just returns “null” thus it doesn’t throw an exception.
                            5. So when to use as keyword and when to use cast expression is a very important question indeed.
                            6. Both have their individual significance.
                            7. Whenever you do not want to raise any exception and you have already handled the returned null value condition then it  is wiser to use “As” keyword.
                            8. But when you want that whenever the object is null an exception should be raised and you are using exception handling then you always must use the same familier cast expressions.

                            Given below is a small code snippet to demonstrate that:-

                             

                             1: using System;
                             2:  
                             3: namespace Ramp.Test
                             4: {
                             5: class Program
                             6: {
                             7: static void Main(string[] args)
                             8: {
                             9: var myObject = new object[3];
                             10: myObject[0] = new Student();
                             11: myObject[1] = new Teacher();
                             12: myObject[2] = "I love C#";
                             13:  
                             14: foreach (object obj in myObject)
                             15: {
                             16: string s = obj as string;
                             17: if(s!=null)
                             18: Console.WriteLine("It is a string");
                             19: else
                             20: {
                             21: Console.WriteLine("Its not a string");
                             22: }
                             23: Console.ReadLine();
                             24: }
                             25: 
                             26: }
                             27: }
                             28: public class Student
                             29: {
                             30: 
                             31: }
                             32: public class Teacher
                             33: {
                             34: 
                             35: }
                             36: }

                             

                            Output

                            Its not a string
                            Its not a string
                            Its a string

                            November 12, 2008

                            Outlook 2007 Signatures:- Using custon HTML and styles in Signatures in Outlook 2007

                            Filed under: Uncategorized — ash143gupta @ 8:06 pm

                            Outlook 2007 does not give the facility to put the custom HTML and styling in Signatures under the signatures box.

                            As you can see that by default when you edit your signatures you only have Delete New Save Rename Options.

                            And also a few options to insert image and some hyperlink but no support for any kind of custom editing of HTML and styles.

                            So what to do if you want to enter some custom HTML and do some styling to your signatures while using Outlook 2007.

                            Here is the workaround.

                            WorkAround

                            Just Navigate to your “C:\Documents and Settings\(your_username)\Application Data\Microsoft\Signatures”.

                            Here Search for the htm file which will generally be starting with you Name.

                            Open this file in Notepad , Notepad++ and add whatever custom content you want to add.

                            Click Save and you are done.

                            Open your Outlook Signatures Box to see that changes made by you are reflected or not.

                            Send a mail to your another account to check whether your custom signatures are working or not.

                            November 9, 2008

                            Adding LinkedIn Button To Blogger or WordPress or any other Blog

                            Filed under: Uncategorized — ash143gupta @ 4:32 pm

                            Today i was trying to add a “LinkedIn” to my linked in profile button on Blogger.But it was not so easy.

                            You can directly embed the HTML and get the linked in image link if you want but for me it didn’t workde.Then i came to know that the linked in people themselves provide custom buttons that you can add anywhere either to your blog or your websites.

                            But these custom button service is rather hidden ie not visible at the first sight.So i thought that it would be helpful if i share this post with you all.

                            Below i have given detailed description with images on how to add this linked in button to your blog.

                            Steps:-

                            1. Just go to http://www.linkedin.com/
                            2. Sign into your profile

                              3.Goto public profile and click the edit button next to your public profile

                                4.Click on promote your profile add custom buttons link

                                5. Now you can see a lot of buttons and their respective code which you can directly paste into your blog.
                                Older Posts »

                                Blog at WordPress.com.