Category Archives: C#

Sisense SSO implementation in MVC .net core

We can find a documentation regarding what needs to be done in Sisense BI Elastic cube manager in relation to SSO using JWT.  They also have C# code to use for SSO but one may be scratching his head if he/she wants to use that sample code in MVC .net Core application.

So for that purpose I’ld suggest to make one controller with one action in it, Use that URL of that controller action to configure in Sisense SSO configuration page. The sample code would be

 

public IActionResult Index([FromQuery]string return_to)
{
TimeSpan t = (DateTime.UtcNow – new DateTime(1970, 1, 1));
int timestamp = (int)t.TotalSeconds;
var payload = new System.Collections.Generic.Dictionary<string, object>() {
{ “iat”, timestamp},
{ “sub”, CurrentUser() },
{ “jti”, Guid.NewGuid() }
// Optional properties
// { “exp”, (int)t.Add(TimeSpan.FromMinutes(30)).TotalSeconds } // Expiration time
};
string token = Jwt.JsonWebToken.Encode(payload, “secret key from sisense sso                 configuration”, Jwt.JwtHashAlgorithm.HS256);
string redirectUrl = “http://URL_of_your_sisense_web_app_with_port/jwt?jwt=&#8221; + token;

    if (return_to != null)
{
redirectUrl += “&return_to=” + UrlEncoder.Default.Encode(return_to);
}
return Redirect(redirectUrl);

  }

}

Building Single Page Applications using Web API and angularJS (Free e-book)

chsakell's Blog

Single Page Applications are getting more and more attractive nowadays for two basic reasons. Website users have always preferred a fluid user experience than one with page reloads and the incredible growth of several JavaScript frameworks such as angularJS. This growth in conjunction with all the powerful server side frameworks makes Single Page Application development a piece of cake. This post is the online version of the free e-book and describes step by step how to build a production-level SPA using ASP.NET Web API 2 and angularJS. You have two choices. Either grab a coffee and keep going on with this version or simply download the e-book and enjoy it whenever and wherever you want.
spa-webapi-angular-28
There are a lot of stuff to build in this application so I will break this post in the following sections:

View original post 9,862 more words

An element with id ‘form1’ could not be found. Script error on page load

When you use Jquery and AJAX on the same form and you included the jQuery file with the <script /> this error will be thrown by VS (specially VS 2010).  To solve this issue just replace the <script /> with <script><script/> tag and it will solve your problem.

Note: This error will only come when you use IE, with every other browser this error will not come, but the thing common on all browsers is that design view is corrupted and the events will not fire as expected or not fire at all

How to set Icon for application .exe file

We have to follow the simple steps when changing an application’s exe file icon.

  • Go to Solution Explorer
  • Right Click on the Primary Project
  • Go to Properties
  • Go to Application tab
  • In Resources groupbox select the desired icon
This will set the application icon for you.
But if you create a setup of your project and there’s a shortcut of your primary .exe file on user’s desktop, you will find that the icon of that is not changed. For that you have to do the following steps.
  • Go to setup project in Solution Explorer
  • Open File System Editor
  • Go to your User’s Desktop folder
  • Select the shortcut of the primary .exe file (if you didn’t find any file here, then you have to create a shortcut of primary .exe file and put it here)
  • Go to properties of this shortcut
  • Select the desired icon for your application.
Now compile and install the application you will find the changed icon of your shortcut file too

How To Create an ASP.NET HTTP Handler by Using Visual C# .NET

From: microsoft support

Implement the Handler

  1. Open Microsoft Visual Studio .NET. In Visual C# .NET, create a new Class Library project named MyHandler.
  2. Set a reference to the System.Web.dll assembly.
  3. Add the following directive to the class:
    Using System.Web
  4. Rename the class SyncHandler.cs, and then change the class definition to reflect this.
  5. Implement the IHttpHandler interface. Your class definition should appear as follows:
    Public Class SyncHandler: IHttpHandler
  6. Implement the IsReusable property and the ProcessRequest method of theIHttpHandler interface. Because this is a synchronous handler, return False for theIsReusable property so that the handler is not pooled.
    public bool IsReusable
    {
    get {return true;}
    }

    public void ProcessRequest(HttpContext context)
    {
    context.Response.Write(“Hello from custom handler”);
    }

  7. Compile the Project

Deploy the Handler

  1. Create a new directory named Handler under the C:\Inetpub\Wwwroot directory.
  2. Create a subdirectory named Bin in the newly created Handler directory. The resultant path is C:\Inetpub\Wwwroot\Handler\Bin.
  3. Copy MyHandler.dll from your project’s Bin\Debug directory to the C:\Inetpub\Wwwroot\Handler\Bin directory.
  4. Follow these steps to mark the new Handler directory as a Web application:
    1. Open Internet Services Manager.
    2. Right-click the Handler directory, and then click Properties.
    3. On the Directory tab, click Create.
  5. Follow these steps to create an application mapping for the handler. For this handler, create a mapping to the Aspnet_isapi.dll file for the *.sync extension. Whenever a .sync file is requested, the request is routed to ASP.NET, and ASP.NET executes the code in the handler.
    1. Right-click on the Handler Web application, and then click Properties.
    2. On the Directory tab, click Configuration.
    3. Click Add to add a new mapping.
    4. In the Executable text box, type the following path: Microsoft Windows 2000:
      C:\WINNT\Microsoft.NET\Framework\<version#>\Aspnet_isapi.dll

      Microsoft Windows XP:

      C:\WINDOWS\Microsoft.NET\Framework\<version#>\Aspnet_isapi.dll
    5. In the Extension text box, type .sync.
    6. Make sure that the Check that file exists check box is cleared, and then clickOK to close the
      Add/Edit Application Extension Mapping dialog box.
    7. Click OK to close the Application Configuration and the Handler Propertiesdialog boxes.
  6. Close Internet Services Manager.

Configure the System

  1. In the C:\Inetpub\Wwwroot\Handler directory, create a new file named Web.config.
  2. Add the following code to Web.config: <configuration> <system.web> <httpHandlers> <add verb="*" path="*.sync" type="MyHandler.SyncHandler, MyHandler" /> </httpHandlers> </system.web> </configuration> In the verb="*" attribute, we instruct the handler to process a request that uses any verb (for example, POST, HEAD, GET, and so on). If you want this handler to process only the POST request, change this to verb="POST". In the path="*.sync" attribute, we instruct the handler to process any incoming requests for files with the .sync extension. In the type="MyHandler.SyncHandler, MyHandler" attribute, we instruct the handler that processes the request to implement in the MyHandler.SyncHandlernamespace, and this class resides in the MyHandler assembly. 

 

How to implement a WCF Service Contract

As I described how to create a Service Contract in the previous post now I will move forward and implement the Service Contract. For this I need to define a class which implements the Interface created for the service Contract.

In the previous post I created a console application for defining a service contract and in Program.cs I defined the service contract. So I am using the same file to write a class code which implements the interface.

The Interface created for the service contract in previous post is as follows.

// Define a service contract.
  [ServiceContract()]
  public interface ICalculator
  {
    // Create the method declaration for the contract.
    [OperationContract]
    double Add(double d1, double d2);
    [OperationContract]
    double Subtract(double d1, double d2);
    [OperationContract]
    double Multiply(double d1, double d2);
    [OperationContract]
    double Divide(double d1, double d2);
  }

Now I will create a class with the name of Calculator which will implement the above mentioned interface.

// Create a class that implements the service contract.
public class Calculator : ICalculator
{
     // Implement functionality for the service operations(methods).
     public double Add(double d1, double d2)
        {
            return d1 + d2;
        }

        public double Subtract(double d1, double d2)
        {
            return d1 - d2;
        }

        public double Multiply(double n1, double n2)
        {
            return d1 * d2;
        }

        public double Divide(double n1, double n2)
        {
            return d1 / d2;
        }
}

	

How to Define a WCF Service Contract

The first step required when creating a Windows Communication Foundation (WCF) service is to create a Contract for the it. The contract specifies what operations a service can perform. In normal programming terms operation can be conceived as method, so we can say operation is a method exposed in a web service. You can write code for web service in .Net compliant language like C#,VB.Net and C++.

Normally we need to create a interface to define the service contract and this contract contains the operations (methods) a service can perform.

Each interface must have the ServiceContract attribute associated with it and the each operation (method) with in the interface should have the OperationContract attribute associated with it. If any operation (method) without OperationContract attribute defined with in the interface that has the ServiceContract attribute, than that funciton will not be exposed to the outer world.

For practice we will create a Console application in the VS 2008 that will contain a interface to show you how to create a service contract. VS 2008 should be run as an administrator and after you create the console application you need to add the reference for System.ServiceModel.

When you create a console application than by default the solution has one file with the name of Program.cs and the code written in it would be like this

namespace Service
{
class Program
{
static void Main(string[] args)
{
}
}
}

I have named the project as Service that’s why the namespace name is also Service.

After adding the reference for System.ServiceModel we also need to add one line of code on top of the file and that line will be a using statement as follows

Using System.ServiceModel;

This line will help the coders to use the classes with in this namespace without writing the full hierarchy of classes.

Now we will create a sample contract for a Web Service which will perform basic arithmetic function like Add,Subtract,Multiply and Division. So the code for this contract should be something like this:

using System;

// Add the using statment for System.ServiceModel 
using System.ServiceModel;
namespace Service
{
  // Define a service contract.
  [ServiceContract()]
  public interface ICalculator
  {
    // Create the method declaration for the contract.
    [OperationContract]
    double Add(double d1, double d2);
    [OperationContract]
    double Subtract(double d1, double d2);
    [OperationContract]
    double Multiply(double d1, double d2);
    [OperationContract]
    double Divide(double d1, double d2);
  }
}

There are many parameter options available for both ServiceContract and OperationContract attribute. We can use them according to our need.

Compile the code and if there is no error than we are succeeded in creating our first Service Contract, which will be used in creating WCF Web Service.

How to Export data from DataTable to Excel

You can find many articles on internet that will provide a solution for exporting data from DataGrid to Excel sheet. i searched many articles on websites and from many articles which provide a solution to this problem but from all those articles the article found at this site.

you may need to change it little according tou your requirements.

private void ExportToExcel(DataTable dt)
{
Microsoft.Office.Interop.Excel.Application objApp;
Microsoft.Office.Interop.Excel._Workbook objBook;

Microsoft.Office.Interop.Excel.Workbooks objBooks;
Microsoft.Office.Interop.Excel.Sheets objSheets;
Microsoft.Office.Interop.Excel._Worksheet objSheet;
Microsoft.Office.Interop.Excel.Range range;

try
{
// Instantiate Excel and start a new workbook.
objApp = new Microsoft.Office.Interop.Excel.Application();
objBooks = objApp.Workbooks;
objBook = objBooks.Add(Type.Missing);
objSheets = objBook.Worksheets;
objSheet = (Microsoft.Office.Interop.Excel._Worksheet)objSheets.get_Item(1);

//Get the range where the starting cell has the address
//m_sStartingCell and its dimensions are m_iNumRows x m_iNumCols.
range = objSheet.get_Range(“A1”, Type.Missing);
range = range.get_Resize(dt.Rows.Count +1 , dt.Columns.Count +1);

//Create an array.
string[,] saRet = new string[dt.Rows.Count+1 ,dt.Columns.Count +1];

for (int col = 0; col <= dt.Columns.Count – 1; col++)
{
saRet[0, col] = dt.Columns[col].ColumnName.ToUpper();
}
bool val = false;
//Fill the array.
for (int iRow = 0; iRow < dt.Rows.Count; iRow++)
{
for (int iCol = 0; iCol < dt.Columns.Count; iCol++)
{
//Put the row and column address in the cell.
if (iCol == 0)
{
saRet[iRow+1, 0] = Convert.ToDateTime(dt.Rows[iRow].ItemArray[0].ToString()).ToShortDateString();
continue;
}

saRet[iRow+1, iCol] = dt.Rows[iRow].ItemArray[iCol].ToString();
}
}

//Set the range value to the array.
range.set_Value(Type.Missing, saRet);

//Return control of Excel to the user.
objApp.Visible = true;
objApp.UserControl = true;
objBook.SaveAs(FileName,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,       Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlShared,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);
}
catch (Exception theException)
{
String errorMessage;
errorMessage = “Error: “;
errorMessage = String.Concat(errorMessage, theException.Message);
errorMessage = String.Concat(errorMessage, ” Line: “);
errorMessage = String.Concat(errorMessage, theException.Source);

MessageBox.Show(errorMessage, “Error”);
}
}

This code  included to format date

public static bool IsDate(string anyString)
{
DateTime dummyDate;
if (anyString == null)
anyString = “”;

if (anyString.Length > 0)
{
try
{
dummyDate = DateTime.Parse(anyString);
}
catch
{
return false;
}
return true;
}
else
{
return false;
}
}
You can also add other checks to insert values as you want to.

Visual Studio Shortcut Keys

You are familiar with many of Visual Studio’s shortcut keys, but not all of them. Here is a handy reference that can make your .NET lifestyle easier and a lot more productive. Note: the ‘must-know’ shortcut keys are highlighted.

General
Shortcut Description
Ctrl-X or
Shift-Delete
Cuts the currently selected item to the clipboard
Ctrl-C or
Ctrl-Insert
Copies the currently selected item to the clipboard
Ctrl-V or
Shift-Insert
Pastes the item in the clipboard at the cursor
Ctrl-Z or
Alt-Backspace
Undo previous editing action
Ctrl-Y or
Ctrl-Shift-Z
Redo the previous undo action
Ctrl-Shift-V or
Ctrl-Shift-Insert
Pastes an item from the clipboard ring tab of the Toolbox at the cursor in the file and automatically selects the pasted item. Cycle through the items on the clipboard by pressing the shortcut keys repeatedly
Esc Closes a menu or dialog, cancels an operation in progress, or places focus in the current document window
Ctrl-S Saves the selected files in the current project (usually the file that is being edited)
Ctrl-Shift-S Saves all documents and projects
Ctrl-P Displays the Print dialog
F7 Switches from the design view to the code view in the editor
Shift-F7 Switches from the code view to the design view in the editor
F8 Moves the cursor to the next item, for example in the TaskList window or Find Results window
Shift-F8 Moves the cursor to the previous item, for example in the TaskList window or Find Results window
Shift-F12 Finds a reference to the selected item or the item under the cursor
Ctrl-Shift-G Opens the file whose name is under the cursor or is currently selected
Ctrl-/ Switches focus to the Find/Command box on the Standard toolbar
Ctrl-Shift-F12 Moves to the next task in the TaskList window
Ctrl-Shift-8 Moves backward in the browse history. Available in the object browser or Class View window
Alt-Left Arrow Go back in the web browser history
Alt-Right Arrow Go forward in the web browser history

Text navigation
Shortcut Description
Left Arrow Moves the cursor one character to the left
Right Arrow Moves the cursor one character to the right
Down Arrow Moves the cursor down one line
Up Arrow Moves the cursor up one line
Page Down Scrolls down one screen in the editor window
Page Up Scrolls up one screen in the editor window
End Moves the cursor to the end of the current line
Home Moves the cursor to the beginning of the line. If you press Home when the cursor is already at the start of the line, it will toggle the cursor between the first non-whitespace character and the real start of the line
Ctrl-End Moves the cursor to the end of the document
Ctrl-Home Moves the cursor to the start of the document
Ctrl-G Displays the Go to Line dialog. If the debugger is running, the dialog also lets you specify addresses or function names to go to
Ctrl-] Moves the cursor to the matching brace in the document. If the cursor is on an opening brace, this will move to the corresponding closing brace and vice versa
Ctrl-K, Ctrl-N Moves to the next bookmark in the document
Ctrl-K, Ctrl-P Moves to the previous bookmark
Ctrl-K, Ctrl-I Displays Quick Info, based on the current language
Ctrl-Down Arrow Scrolls text down one line but does not move the cursor. This is useful for scrolling more text into view without losing your place. Available only in text editors
Ctrl-Up Arrow Scrolls text up one line but does not move the cursor. Available only in text editors
Ctrl-Right Arrow Moves the cursor one word to the right
Ctrl-Left Arrow Moves the cursor one word to the left
Ctrl-Shift-1 Navigates to the next definition, declaration, or reference of an item. Available in the object browser and Class View window. Also available in source editing windows if you have already used the Edit.GoToReference (Shift-F12) shortcut
Ctrl-Shift-2 Navigates to the previous definition, declaration, or reference of an item

Shortcut Description
Enter Inserts a new line
Delete Deletes one character to the right of the cursor
Insert Toggles between insert and overtype insertion modes
Tab Indents the currently selected line or lines by one tab stop. If there is no selection, this inserts a tab stop
Shift-Tab Moves current line or selected lines one tab stop to the left
Backspace or
Shift-Backspace
Deletes one character to the left of the cursor
Ctrl-K, Ctrl-C Marks the current line or selected lines of code as a comment, using the correct comment syntax for the programming language
Ctrl-K, Ctrl-U Removes the comment syntax from the current line or currently selected lines of code
Ctrl-T or
Shift-Enter
Swaps the characters on either side of the cursor. (For example, AC|BD becomes AB|CD.) Available only in text editors
Ctrl-K, Ctrl-L Removes all unnamed bookmarks in the current document
Ctrl-M, Ctrl-O Automatically determines logical boundaries for creating regions in code, such as procedures, and then hides them. This collapses all such regions in the current document
Alt-Right Arrow or
Ctrl-Spacebar
Displays statement completion based on the current language or autocompletes word if existing text unambiguously identifies a single symbol
Ctrl-K, Ctrl-\ Removes horizontal whitespace in the selection or deletes whitespace adjacent to the cursor if there is no selection
Ctrl-K, Ctrl-F Applies the indenting and space formatting for the language as specified on the Formatting pane of the language in the Text Editor section of the Options dialog to the selected text.
Ctrl-L Cuts all selected lines or the current line if nothing has been selected to the clipboard
Ctrl-Shift-L Deletes all selected lines or the current line if no selection has been made
Ctrl-Enter Inserts a blank line above the cursor
Ctrl-Shift-Enter Inserts a blank line below the cursor
Shift-Alt-T Moves the line containing the cursor below the next line
Ctrl-J Lists members for statement completion when editing code
Ctrl-U Changes the selected text to lowercase characters
Ctrl-Shift-U Changes the selected text to uppercase characters
Ctrl-Shift-Spacebar Displays a tooltip that contains information for the current parameter, based on the current language
Ctrl-M, Ctrl-U Removes the outlining information for the currently selected region
Ctrl-M, Ctrl-P Removes all outlining information from the entire document
Ctrl-R, Ctrl-P Swaps the anchor and endpoint of the current selection
Ctrl-M, Ctrl-L Toggles all previously marked hidden text sections between hidden and display states
Ctrl-K, Ctrl-K Sets or removes a bookmark at the current line
Ctrl-M, Ctrl-M Toggles the currently selected hidden text section or the section containing the cursor if there is no selection between the hidden and display states
Ctrl-K, Ctrl-H Sets or removes a shortcut in the tasklist to the current line
Ctrl-R, Ctrl-R Enables or disables word wrap in an editor
Ctrl-R, Ctrl-W Shows or hides spaces and tab marks
Ctrl-Delete Deletes the word to the right of the cursor
Ctrl-Backspace Deletes the word to the left of the cursor
Ctrl-Shift-T Transposes the two words that follow the cursor. (For example, |End Sub would be changed to read Sub End|.)

Text selection
Shortcut Description
Shift-Left Arrow Moves the cursor to the left one character, extending the selection
Shift-Alt-Left Arrow Moves the cursor to the left one character, extending the column selection
Shift-Right Arrow Moves the cursor to the right one character, extending the selection
Shift-Alt-Right Arrow Moves the cursor to the right one character, extending the column selection
Ctrl-Shift-End Moves the cursor to the end of the document, extending the selection
Ctrl-Shift-Home Moves the cursor to the start of the document, extending the selection
Ctrl-Shift-] Moves the cursor to the next brace, extending the selection
Shift-Down Arrow Moves the cursor down one line, extending the selection
Shift-Alt-Down Arrow Moves the cursor down one line, extending the column selection
Shift-End Moves the cursor to the end of the current line, extending the selection
Shift-Alt-End Moves the cursor to the end of the line, extending the column selection
Shift-Home Moves the cursor to the start of the line, extending the selection
Shift-Alt-Home Moves the cursor to the start of the line, extending the column selection
Shift-Up Arrow Moves the cursor up one line, extending the selection
Shift-Alt-Up Arrow Moves the cursor up one line, extending the column selection
Shift-Page Down Extends selection down one page
Shift-Page Up Extends selection up one page
Ctrl-A Selects everything in the current document
Ctrl-W Selects the word containing the cursor or the word to the right of the cursor
Ctrl-= Selects from the current location in the editor back to the previous location in the navigation history
Ctrl-Shift-Page Down Moves the cursor to the last line in view, extending the selection
Ctrl-Shift-Page Up Moves the cursor to the top of the current window, extending the selection
Ctrl-Shift-Alt-Right Arrow Moves the cursor to the right one word, extending the column selection
Ctrl-Shift-Left Arrow Moves the cursor one word to the left, extending the selection
Ctrl-Shift-Alt-Left Arrow Moves the cursor to the left one word, extending the column selection

Project related
Shortcut Description
Ctrl-Shift-B Builds the solution
Ctrl-N Displays the New File dialog. Note: files created this way are not associated with a project. Use Ctrl-Shift-A to add a new file in a project
Ctrl-Shift-N Displays the New Project dialog
Ctrl-O Displays the Open File dialog
Ctrl-Shift-O Displays the Open Project dialog
Shift-Alt-A Displays the Add Existing Item dialog
Ctrl-Shift-A Displays the Add New Item dialog
Ctrl-Alt-Insert Allows you to override base class methods in a derived class when an overridable method is highlighted in the Class View pane

Window manipulation
Shortcut Description
Shift-Alt-Enter Toggles full screen mode
Ctrl-+ Goes back to the previous location in the navigation history. (For example, if you press Ctrl-Home to go to the start of a document, this shortcut will take the cursor back to wherever it was before you pressed Ctrl-Home.)
Ctrl-Shift-+ Moves forward in the navigation history. This is effectively an undo for the View.NavigateBackward operation
Ctrl-F4 Closes the current MDI child window
Shift-Esc Closes the current tool window
Ctrl-F2 Moves the cursor to the navigation bar at the top of a code view
Ctrl-Tab Cycles through the MDI child windows one window at a time
Ctrl-F6,
Ctrl-Shift-Tab
Moves to the previous MDI child window
Alt-F6,
Ctrl-Shift-F6
Moves to the next tool window
Shift-Alt-F6 Moves to the previously selected window
F6 Moves to the next pane of a split pane view of a single document
Shift-F6 Moves to the previous pane of a document in split pane view
Ctrl-Pagedown Moves to the next tab in the document or window (e.g., you can use this to switch the HTML editor from its design view to its HTML view
Ctrl-PageUp Moves to the previous tab in the document or window

Control editor (designer)
Shortcut Description
Ctrl-Down Arrow Moves the selected control down in increments of one on the design surface

Down Arrow
Moves the selected control down to the next grid position on the design surface
Ctrl-Left Arrow Moves the control to the left in increments of one on the design surface
Left Arrow Moves the control to the left to the next grid position on the design surface
Ctrl-Right Arrow Moves the control to the right in increments of one on the design surface
Right Arrow Moves the control to the right into the next grid position on the design surface
Ctrl-Up Arrow Moves the control up in increments of one on the design surface
Up Arrow Moves the control up into the next grid position on the design surface
Tab Moves to the next control in the tab order
Shift-Tab Moves to the previous control in the tab order
Ctrl-Shift-Down Arrow Increases the height of the control in increments of one on the design surface
Shift-Down Arrow Increases the height of the control to the next grid position on the design surface
Ctrl-Shift-Left Arrow Reduces the width of the control in increments of one on the design surface
Shift-Left Arrow Reduces the width of the control to the next grid position on the design surface
Ctrl-Shift-Right Arrow Increases the width of the control in increments of one on the design surface
Shift-Left Arrow Increases the width of the control to the next grid position on the design surface
Ctrl-Shift-Up Arrow Decreases the height of the control in increments of one on the design surface
Shift-Up Arrow Decreases the height of the control to the next grid position on the design surface

Search and replace
Shortcut Description
Ctrl-F Displays the Find dialog
Ctrl-Shift-F Displays the Find in Files dialog
F3 Finds the next occurrence of the previous search text
Ctrl-F3 Finds the next occurrence of the currently selected text or the word under the cursor if there is no selection
Shift-F3 Finds the previous occurrence of the search text
Ctrl-Shift-F3 Finds the previous occurrence of the currently selected text or the word under the cursor
Ctrl-D Places the cursor in the Find/Command line on the Standard toolbar
Alt-F3, H Selects or clears the Search Hidden Text option for the Find dialog
Ctrl-I Starts an incremental search—after pressing Ctrl-I, you can type in text, and for each letter you type, VS.NET will find the first occurrence of the sequence of letters you have typed so far. This is a very convenient facility, as it lets you find text by typing in exactly as many characters as are required to locate the text and no more. If you press Ctrl-I a second time without typing any characters, it recalls the previous pattern. If you press it a third time or you press it when an incremental search has already found a match, VS.NET searches for the next occurrence.
Alt-F3, C Selects or clears the Match Case option for Find and Replace operations
Alt-F3, R Selects or clears the Regular Expression option so that special characters can be used in Find and Replace operations
Ctrl-H Displays the Replace dialog
Ctrl-Shift-H Displays the Replace in Files dialog
Ctrl-Shift-I Performs an incremental search in reverse direction
Alt-F3, S Halts the current Find in Files operation
Alt-F3, B Selects or clears the Search Up option for Find and Replace operations
Alt-F3, W Selects or clears the Match Whole Word option for Find and Replace operations
Alt-F3, P Selects or clears the Wildcard option for Find and Replace operations

Help
Shortcut Description
Ctrl-Alt-F1 Displays the Contents window for the documentation
Ctrl-F1 Displays the Dynamic Help window, which displays different topics depending on what items currently have focus. If the focus is in a source window, the Dynamic Help window will display help topics that are relevant to the text under the cursor
F1 Displays a topic from Help that corresponds to the part of the user interface that currently has the focus. If the focus is in a source window, Help will try to display a topic relevant to the text under the cursor
Ctrl-Alt-F2 Displays the Help Index window
Shift-Alt-F2 Displays the Index Results window, which lists the topics that contain the keyword selected in the Index window
Alt-Down Arrow Displays the next topic in the table of contents. Available only in the Help browser window
Alt-Up Arrow Displays the previous topic in the table of contents. Available only in the Help browser window
Ctrl-Alt-F3 Displays the Search window, which allows you to search for words or phrases in the documentation
Shift-Alt-F3 Displays the Search Results window, which displays a list of topics that contain the string searched for from the Search window.
Shift-F1 Displays a topic from Help that corresponds to the user interface item that has the focus

Debugging
Shortcut Description
Ctrl-Alt-V, A Displays the Auto window to view the values of variables currently in the scope of the current line of execution within the current procedure
Ctrl-Alt-Break Temporarily stops execution of all processes in a debugging session. Available only in run mode
Ctrl-Alt-B Displays the Breakpoints dialog, where you can add and modify breakpoints
Ctrl-Alt-C Displays the Call Stack window to display a list of all active procedures or stack frames for the current thread of execution. Available only in break mode
Ctrl-Shift-F9 Clears all of the breakpoints in the project
Ctrl-Alt-D Displays the Disassembly window
Ctrl-F9 Enables or disables the breakpoint on the current line of code. The line must already have a breakpoint for this to work
Ctrl-Alt-E Displays the Exceptions dialog
Ctrl-Alt-I Displays the Immediate window, where you can evaluate expressions and execute individual commands
Ctrl-Alt-V, L Displays the Locals window to view the variables and their values for the currently selected procedure in the stack frame
Ctrl-Alt-M, 1 Displays the Memory 1 window to view memory in the process being debugged. This is particularly useful when you do not have debugging symbols available for the code you are looking at. It is also helpful for looking at large buffers, strings, and other data that does not display clearly in the Watch or Variables window
Ctrl-Alt-M, 2 Displays the Memory 2 window
Ctrl-Alt-M, 3 Displays the Memory 3 window
Ctrl-Alt-M, 4 Displays the Memory 4 window
Ctrl-Alt-U Displays the Modules window, which allows you to view the .dll or .exe files loaded by the program. In multiprocess debugging, you can right-click and select Show Modules for all programs
Ctrl-B Opens the New Breakpoint dialog
Ctrl-Alt-Q Displays the Quick Watch dialog with the current value of the selected expression. Available only in break mode. Use this command to check the current value of a variable, property, or other expression for which you have not defined a watch expression
Ctrl-Alt-G Displays the Registers window, which displays CPU register contents
Ctrl-Shift-F5 Terminates the current debugging session, rebuilds if necessary, and then starts a new debugging session. Available in break and run modes
Ctrl-Alt-N Displays the Running Documents window that displays the set of HTML documents that you are in the process of debugging. Available in break and run modes
Ctrl-F10 Starts or resumes execution of your code and then halts execution when it reaches the selected statement. This starts the debugger if it is not already running
Ctrl-Shift-F10 Sets the execution point to the line of code you choose
Alt-NUM * Highlights the next statement to be executed
F5 If not currently debugging, this runs the startup project or projects and attaches the debugger. If in break mode, this allows execution to continue (i.e., it returns to run mode).
Ctrl-F5 Runs the code without invoking the debugger. For console applications, this also arranges for the console window to stay open with a “Press any key to continue” prompt when the program finishes
F11 Executes code one statement at a time, tracing execution into function calls
Shift-F11 Executes the remaining lines of a function in which the current execution point lies
F10 Executes the next line of code but does not step into any function calls
Shift-F5 Available in break and run modes, this terminates the debugging session
Ctrl-Alt-V, T Displays the This window, which allows you to view the data members of the object associated with the current method
Ctrl-Alt-H Displays the Threads window to view all of the threads for the current process
F9 Sets or removes a breakpoint at the current line
Ctrl-F11 Displays the disassembly information for the current source file. Available only in break mode
Ctrl-Alt-W, 1 Displays the Watch 1 window to view the values of variables or watch expressions
Ctrl-Alt-W, 2 Displays the Watch 2 window
Ctrl-Alt-W, 3 Displays the Watch 3 window
Ctrl-Alt-W, 4 Displays the Watch 4 window
Ctrl-Alt-P Displays the Processes dialog, which allows you to attach or detach the debugger to one or more running processes

Object browser
Shortcut Description
Alt-F12 Displays the Find Symbol dialog
Ctrl-F12 Displays the declaration of the selected symbol in the code
F12 Displays the definition for the selected symbol in code
Ctrl-Alt-F12 Displays the Find Symbol Results window
Ctrl-Alt-J Displays the Object Browser to view the classes, properties, methods, events, and constants defined either in your project or by components and type libraries referenced by your project
Alt-+ Moves back to the previously selected object in the selection history of the object browser
Shift-Alt-+ Moves forward to the next object in the selection history of the object browser

Tool window
Shortcut Description
Ctrl-Shift-M Toggles the Command window into or out of a mode allowing text within the window to be selected
Ctrl-Shift-C Displays the Class View window
Ctrl-Alt-A Displays the Command window, which allows you to type commands that manipulate the IDE
Ctrl-Alt-T Displays the Document Outline window to view the flat or hierarchical outline of the current document
Ctrl-Alt-F Displays the Favorites window, which lists shortcuts to web pages
Ctrl-Alt-O Displays the Output window to view status messages at runtime
F4 Displays the Properties window, which lists the design-time properties and events for the currently selected item
Shift-F4 Displays the property pages for the item currently selected. (For example, use this to show a project’s settings.)
Ctrl-Shift-E Displays the Resource View window
Ctrl-Alt-S Displays the Server Explorer window, which allows you to view and manipulate database servers, event logs, message queues, web services, and many other operating system services
Ctrl-Alt-R Displays the web browser window, which allows you to view pages on the Internet
Ctrl-Alt-L Displays the Solution Explorer, which lists the projects and files in the current solution
Ctrl-Alt-K Displays the TaskList window, which displays tasks, comments, shortcuts, warnings, and error messages
Ctrl-Alt-X Displays the Toolbox, which contains controls and other items that can be dragged into editor and designer windows

Html editor (Design View)
Shortcut Description
Ctrl-B Toggles the selected text between bold and normal
Ctrl-Shift-T Decreases the selected paragraph by one indent unit
Ctrl-T Indents the selected paragraph by one indent unit
Ctrl-I Toggles the selected text between italic and normal
Ctrl-Shift-K Prevents an absolutely positioned element from being inadvertently moved. If the element is already locked, this unlocks it
Ctrl-G Toggles the grid
Ctrl-Shift-G Specifies that elements be aligned using an invisible grid. You can set grid spacing on the Design pane of HTML designer options in the Options dialog, and the grid will be changed the next time you open a document
Ctrl-U Toggles the selected text between underlined and normal
Ctrl-Shift-L Displays the Bookmark dialog
Ctrl-J Inserts <div></div> in the current HTML document
Ctrl-L When text is selected, displays the Hyperlink dialog
Ctrl-Shift-W Displays the Insert Image dialog
Ctrl-Alt-Up Arrow Adds one row above the current row in the table
Ctrl-Alt-Down Arrow Adds one row below the current row in the table
Ctrl-Alt-Left Arrow Adds one column to the left of the current column in the table
Ctrl-Alt-Right Arrow Adds one column to the right of the current column in the table
Ctrl-Shift-Q Toggles display of marker icons for HTML elements that do not have a visual representation, such as comments, scripts, and anchors for absolutely positioned elements
Ctrl-Page Down Switches from design view to HTML view and vice versa
Ctrl-Q Displays a 1-pixel border around HTML elements that support a BORDER attribute and have it set to zero, such as tables, table cells, and divisions

  1. Shortcut Description
    Alt-F8 Displays the Macro Explorer window, which lists all available macros
    Alt-F11 Launches the macros IDE
    Ctrl-Shift-R Places the environment in macro record mode or completes recording if already in record mode
    Ctrl-Shift-P Plays back a recorded macro