Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for January, 2010

How to manually remove programs from the Add or Remove Programs tool

The Currently installed programs list in the Add or Remove Programs tool lists all of the Windows-compatible programs that have an uninstall program or feature. Occasionally, a program may not be removed completely, and the registry key that is used to display the program in the Currently installed programs list remains. In this situation, you may need to manually remove the program from the Currently installed programs list in Add or Remove Programs. To do this, follow these steps.image

  1. Click Start, and then click Run.
  2. In the Open box, type regedt32, and then click OK.
  3. In Registry Editor, locate the following registry key:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

  4. In the left pane, click the Uninstall registry key, and then click Export on the File menu.
  5. In the Export Registry File dialog box that appears, click Desktop in the Save in list, type uninstall in the File name box, and then click Save.
  6. Each key listed under Uninstall in the left pane of Registry Editor represents a program that is displayed in the Currently installed programs list of the Add or Remove Programs tool. To determine which program that each key represents, click the key, and then view the following values in the details pane on the right:

    DisplayName: The value data for the DisplayName key is the name that is listed in Add or Remove Programs.
    -and-
    UninstallString: The value data for the UninstallString key is the program that is used to uninstall the program.

  7. After you identify the registry key that represents the program that you removed but which is still displayed in the Currently installed programs list of Add or Remove Programs, right-click the key in the left pane of the Registry Editor window, and then click Delete.
    Click Yes in response to the "Are you sure you want to delete this key and all of its subkeys?" message.
  8. On the File menu, click Exit to quit Registry Editor.
  9. Click Start, click Control Panel, and then click Add or Remove Programs.
    In the Currently installed programs list, verify that the program whose registry key you deleted is no longer listed.
  10. Do one of the following:
    • If the program list is not correct in Add or Remove Programs, double-click the Uninstall.reg file that you saved to your desktop in step 5 to restore the original list of programs in the registry.
      -or-
    • If the program list is correct in Add or Remove Programs, right-click the Uninstall.reg file on your desktop, and then click Delete.
  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

TODO Comments in Visual Studio

Using TODO

imageTODO comments allow you to tell Visual Studio to maintain a central list of tasks, which it reads from many different places in your code. The Task List is a panel or floating window in Visual Studio that will display all the TODO comments in your project. To open the list, go to View menu -> Task List.

Some example TODO comments

You probably have a lot of code that needs a lot of work. If you don’t, then you need to write code that needs a lot of work. Here are some examples of TODO lines that Visual Studio 2008 will notice and put into its special Task Pane.

//todo: your task 1
//TODO: your task 2
// Todo your task 3

Description of example. This will appear in your tasks pane as a separate task. Note that you have some flexibility with these tokens. The strings "todo", "TODO", and "TODO" all work equally well—Visual Studio’s parser gives you a little bit of freedom.

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

Tips and Tricks for the Visual Studio .NET IDE

1. Record and play temporary macro

Ctrl+Shift+R to record a new temporary macro. Press Ctrl+Shift+R to stop recording. Ctrl+Shift+P to play the recorded macro.

This works similar to *recording* in Vim. If you think you are going to be repeating a set of keyboard keys, then record them once and play them each time after.

2. Multiple copy/pastes

Ctrl+Shift+V cycles through the clipboard ring. You can copy/cut multiple times from one area of code, then go to another area and paste them one after another.

3. Drag and drop code snippets

The Toolbox (Ctrl+Alt+X) window has multiple tabs. You can drag and drop code onto this window and copy it elsewhere. Some tabs do not allow dropping code into them; those that allow will have the appropriate icon. The General tab works for me.

4. Previous cursor positions

Ctrl+- i.e. Ctrl + Hyphen. This cycles you through the code positions you visited.

Ctrl+Shift+- to navigate in the opposite direction.

5. Incremental search

To incrementally search for text as you type, first press Ctrl+i. Then type the word you want to search. Hit backspace to clear a character and enter to finish. Pressing F3 after this will work as usual, i.e. search for the next occurrence of previous search.

Ctrl+iCtrl+i works like F3.

6. Matching brace/comment/region/quote

Ctrl+] takes you to the matching brace. It also takes you to the matching comment, region or quote depending on what is at the cursor now.

7. Vertical block selection

Press Alt and then select the area you want with your mouse.

8. Closing/Showing support windows

There are a bunch of necessary/useful windows in the Visual Studio IDE like Properties (F4), Solution Explorer (Ctrl+Alt+L), Output Window (Ctrl+Alt+O), Task List (Ctrl+Alt+K) etc. However, they take up a lot of space. An easy way around this is to use the auto hide feature.

Open the window you want. Right click on its title and choose Auto Hide. The window will dock in whenever your mouse is not hovering over it.

9. Tab groups – group code editor windows

If you have many source code windows open, you can group them logically using tab groups. Right click the tab of the code window and choose New Horizontal Tab Group. This will move the window into a split window, allowing you to see both files. You can add more files to this new tab group and also move files back to the previous group by choosing Move To Previous Tab Group.

10. Track things you have to do with Task List

The Task List window (Ctrl+Alt+K) allows you to keep track of the things you have to do. Right click on the Task List window and choose Show Tasks|All to see a list of tasks. Ctrl+Shift+F12 to cycle through your list of tasks.

By default, comments marked with a TODO will appear in the task list.

11. Edit Task List Comment Tokens

You can add your own set of comment tokens (like the TODO comment token). Goto Tools|Options|Environment|Task List|Comment Tokens and make your changes. You can change the priority appearance of each comment token too.

12. Add Task List Shortcut

Add a shortcut to the task list with Ctrl+K, Ctrl+H. This will add the current line to the task list.

13. Auto-complete

Press Ctrl+Space or Alt+RightArrow to auto-complete the word. Intellisense suggestions may pop up a window if there is more than one possibility.

14. Intellisense suggestions window

Press Ctrl+Shift+Space to bring up the intellisense suggestions window. When giving parameters for functions, I often need to escape the suggestions window to check another part of code. To bring it back, I used to delete a comma and then type it again; but this is easier.

15. Word wrap

Ctrl+R Ctrl+R

or

Tools|Options|Text Editor|All Languages|General|Word Wrap

If you want to set this option for only one language, then choose the appropriate language instead of All Languages.

16. Line numbering

Tools|Options|Text Editor|All Languages|General|Line numbers.

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

asp.net Interview: Can you explain the difference between an ADO.NET Dataset and an ADO Recordset

Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?

  • You can store many edits in a DataSet, and write them to the original data source in a single operation. seo-job-interview
  • Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.
  • There’s no concept of cursor types in a DataSet.
  • A DataSet is designed to work without any continuing connection to the original data source.
  • A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
  • Data in a DataSet is bulk-loaded, rather than being loaded on demand.
  • DataSets have no current record pointer You can use For Each loops to move through the data.
  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

Interview Questions on asp.net

  • Whats MSIL, and why should my developers need an appreciation of it if at all? MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL. asp.net-design-logo
  • Which method do you invoke on the DataAdapter control to load your generated dataset with data? The .Fill() method
  • Can you edit data in the Repeater control? No, it just reads the information from its data source
  • What base class do all Web Forms inherit from? The Page class.
  • Name two properties common in every validation control? ControlToValidate property and Text property.
  • What tags do you need to add within the asp:datagrid tags to bind columns manually? Set AutoGenerateColumns Property to false on the datagrid tag
  • How can you provide an alternating color scheme in a Repeater control? Use the AlternatingItemTemplate
  • What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control? You must set the DataSource property and call the DataBind method.
  • What tag do you use to add a hyperlink column to the DataGrid? <asp:HyperLinkColumn>
  • What is the transport protocol you use to call a Web service? SOAP is the preferred protocol.
  • True or False: A Web service can only be written in .NET? False
  • What does WSDL stand for? (Web Services Description Language)
  • Explain what a diffgram is, and a good use for one? The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. For reading database data to an XML file to be sent to a Web Service.
  • Which template must you provide, in order to display data in a Repeater control? ItemTemplate
    • Digg
    • DZone
    • Yahoo Buzz
    • Delicious
    • Reddit
    • StumbleUpon
    • SmakNews
    • Jumptags
    • Ping
    • Share/Bookmark

    ASP.NET Interview Questions and Answers

    1. Explain the differences between Server-side and Client-side code?
    Server-side code executes on the server. Client-side code executes in the client’s browser.aspnet

    2. What type of code (server or client) is found in a Code-Behind class?
    Server-side code. Since code-behind is executed on the server. However, during the code-behind’s execution on the server, it can render client-side code such as JavaScript to be processed in the clients browser. But just to be clear, code-behind executes on the server, thus making it server-side code.

    3. Should user input data validation occur server-side or client-side?
    All user input data validation should occur on the server at a minimum. Additionally, client-side validation can be performed where deemed appropriate and feasable to provide a richer, more responsive experience for the user.

    4. What is the difference between Server.Transfer and Response.Redirect?
    Why would I choose one over the other? Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client’s browser. This provides a faster response with a little less overhead on the server. Server.Transfer does not update the clients url history list or current url. Response.Redirect is used to redirect the user’s browser to another page or site. This performas a trip back to the client where the client’s browser is redirected to the new page. The user’s browser history list is updated to reflect the new address.

    5. What is the Global.asax used for?
    The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.

    6. What are the Application_Start and Session_Start subroutines used for?
    This is where you can set the specific variables for the Application and Session objects.

    7. Whats an assembly?
    Assemblies are the building blocks of the .NET framework.

    8. Can you explain what inheritance is and an example of when you might use it?
    When you want to inherit (use the functionality of) another class. Example: With a base class named Employee, a Manager class could be derived from the Employee base class.

    9. Describe the difference between inline and code behind.
    Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.

    10. Explain what a diffgram is, and a good use for one?
    The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service.

    • Digg
    • DZone
    • Yahoo Buzz
    • Delicious
    • Reddit
    • StumbleUpon
    • SmakNews
    • Jumptags
    • Ping
    • Share/Bookmark