Welcome to MSDN Blogs Sign in | Join | Help
Tip #86: Did you know… Visual Studio has several different search options?

The standard methods for searching can be found under the Edit --> Find and Replace menu.

EditFindReplaceMenu

The “Quick Find” method (Ctrl+F) allows users to search inside of the current document, all open documents, the current project, the entire solution, and the current block by changing the Look in selection.

 

QuickFindLookIn

If you set Look in to be the current project or the entire solution, Visual studio will open files that have matches as you navigate between matches.

You can also adjust the settings under Find options to make the searches more specific by having them match on case or whole words or control how it searches by deciding whether it should search up or down or if it should look at hidden text (collapsed regions).

QuickFindFindOption

The Find in Files method (Ctrl+Shift+F) allows users to see all the occurrences of the search in one place, changes the Look in options by removing the current block, but allows users to search custom locations by using the “…” button next to the Look in drop down, and allows the user to restrict the types of files searched.

FindInFiles

If you use Ctrl+F or select the Quick Find option from the find and replace menu by mistake, hitting Ctrl+Shift+F or selecting the drop down in the upper left corner of the dialog and selecting Find In Files will quickly get you to the Find in Files dialog.

Using the Result options section you choose to have the results displayed in either the “Find Results 1” or “Find results 2” window. Allowing you to switch between results if needed.

The Find What field also keeps a history of searches. To access this history click the down arrow of the Find What field. You can avoid using the history or typing search terms by having the value you want to search for selected in the editor before opening one of the find dialogs.

Ben Byrd
SDET | Visual Web Developer

Tip#85: Did you know… You can now do Multiple Selection of controls in your Designer with VS 2008 SP1?

Visual Web developer 2008 SP1 supports multiple selection of controls on your designer using Ctrl+Click.

You can see that the designer:

  • Displays the primary selected control with a white tab. Button3 in the image below.
  • Enable you to set property for the selected controls using Property Grid. Note that the property grid would show you only the properties that are in common for all the selected controls.
  • Enables you to make use of the Align, Make Same Size and Order Menu commands in your Format Menu options.

However VWD 2008 SP1 does not support the ability to drag drop multiple controls and Cut/Copy/Paste of multiple elements.

MultipleSelection

Thanks!

Reshmi Mangalore

SDET, Visual Web Developer

Tip #84: Did you know… How to set a Start page for your Web Site in Visual Web Developer?

As you are developing your site, you may want to start at a particular page for testing your web site. By defaults, when you start debugging, Visual Studio runs the page that was currently in focus in your designer.

If you set this page, Visual web Developer will start your web site with the Set Page and not the current page in designer.

You can do this by right-click on the page and selecting Set As Start Page option from the context menu.

Set as Start Page

This could also be set in Properties page under the Start Options tab as shown below.

StartOptions

Enjoy!

Reshmi Mangalore

SDET, Visual Web Developer

Tip #83: Did you know... You can get the name of the calling method from the stack using reflection?

Nearly every program needs a logger to log events, errors and exceptions. Sometimes it is also useful to log the name of the method that logged the event. The easiest way to do that is to make the log method take both the calling method name and event as parameters:

[C#]

void Log(string callingMethodName, string eventMessage) 

{
   Console.WriteLine("Event logged by " + callingMethodName);
   Console.WriteLine("Event: " + eventMessage);
}

In this case, every method will need to specify its name when calling Log(). In addition to this, the developer will have to watch if methods name change. However, there is a cleaner way to get the name of the calling method. It can be extracted from the stack. Since the method on top of the stack is the method that is currently being executed, the calling method will be right below it. Thus, by instantiating StackTrace (don’t forget to include System.Diagnostics) and getting the frame with index 1 will result in getting a StackFrame that corresponds to the call from the calling method. Finally, reflection can be used to get method name.

using System.Diagnostics;
	
void Log(string eventMessage) {
   Console.WriteLine("Event logged by " + (new StackTrace()).GetFrame(1).GetMethod().Name);
   Console.WriteLine("Event: " + eventMessage);
}


Katerina Rohonyan
SDET, IIS Team

Tip #82: Did you know... How to migrate Visual Studio 2005 Web Application Project to Visual Studio 2008

Following steps highlight how a Visual Studio 2005 Web application project can be migrated to Visual Studio 2008.

  1. Take backup of the original project
  2. Open Visual Studio 2008
  3. Click File -> Open Project and browse to the folder to open the project
  4. You will receive the following conversion wizard to help you convert the solution or project to the current version. Click Next.

    image

  5. Select Yes on this screen if you want the wizard to help you to take the backup, otherwise select No and Click Next.

     image

  6. Be sure to read the summary on this screen & click finish

    image 

  7. As soon as you click finish, you will see an upgrade prompt. Click yes if you want to upgrade to the latest framework otherwise Click No. If you select yes to upgrade, the project file as well as web.config file is updated for the latest framework. It's recommended to select the checkbox to do the same for all webs in this solution.

    image
  8. The conversion wizard would show you the status, select Show the log to see the log and click close.

    image

 

For projects using Ajax you might need to install ASP.NET Ajax Extensions 1.0 in VS 2008 if you said no to upgrade. Please see Tip #62 to learn how to install it.

Hope this helps,

Deepak Verma
SDET | Visual Web Developer

Tip #81: Did you know... How to Select the CSS Schema for Intellisense and CSS Properties?

In Visual Studio 2008, there is a Style Sheet Toolbar (visible only when a CSS file is active) which allows the user to select a CSS Schema, as seen in this screen shot:

 css1

However, this setting only affects the CSS editor, not the Intellisense in aspx or html files, nor the properties/values displayed in the CSS Property Grid, as shown here:

css2

Setting the CSS schema for aspx/html pages is actually a bit obscure; in VS 2008 the current CSS schema in use is deduced rather than selected, and the setting is not displayed. The CSS schema is selected to complement the HTML schema, selected via the HTML Source Editing Toolbar, as shown below:

css3

Selecting a “Target Schema for Validation” in the HTML Source Editing Toolbar implicitly selects a corresponding CSS schema, which is used in all aspx/html and similar documents opened in the web designer (documents with Design/Split/Source buttons displayed at the bottom of the window.)

Here is the table of correspondence for Visual Studio 2008:

HTML Schema CSS Schema
Internet Explorer 6.0 Internet Explorer 6.0
Internet Explorer 3.02/Netscape Navigator 3.0 CSS 1.0
Netscape Navigator 4.0 CSS 2.1*
HTML 4.01 CSS 1.0
XHTML 1.0 Transitional CSS 2.0
XHTML 1.0 Frameset CSS 2.0
XHTML 1.1 CSS 2.1

* For Netscape Navigator 4.0, no CSS schema is specified, but CSS 2.1 is used.

Hope this helps!

Van Kichline

SDET | Visual Web Developer

Tip #80: Did you know… How to show JScript validation errors as warnings?

With Visual Studio 2008 RTM, JScript validation setting is an option on the HTML validation page on the Options dialog. Since Visual Studio 2008 SP1 and later, we added a new option page JScript on the Options dialog, see the blog "Introducing JScript Formatting in VS 2008 SP1" for more detail. With this change, now the JScript validation resides on its own tab "Miscellaneous" as shown below:

JScript

To view JScript errors as warnings, we need to launch Options dialog from Tool -> Options menu, then expand Text Editor -> JScript -> Miscellaneous, check the checkbox "Show errors as warnings". Some users like to have JScript syntax errors shown in the Error List since it would encourage standard compliance, while others don't like to deal with validation errors since they are browser errors.

Anh Phan

SDET, Visual Web Developer

Tip #79: Did you know… How to quickly comment and uncomment in your web pages?

Select the lines you want to be commented in your ASPX, HTML, web config file etc  and click on the Comment/ Uncomment icon in Toolbar.

The comment icon looks like this:

 Comment Icon

The icon for uncomment looks like:

Uncomment

Alternatively you can use  Keyboard shortcut Ctrl+K Ctrl+C to comment and use Ctrl+K Ctrl+U to uncomment.

Comments in ASPX page…

Comments in ASPX page

Comment in HTML page…

Comments in HTML page

Comment in script blocks…

Script block

This shortcut is available under Edit Menu->Advance –>Comment Selection /Uncomment Selection.

Comment Uncomment Menu Option

Enjoy!

Reshmi Mangalore

SDET| Visual Web Developer

Tip# 78: Did you know… How to navigate using Document Outline?

Document Outline window can be launched from the menu View -> Document Outline, or via short cut key Ctrl-Alt-T. The Document Outline window displays a nested, hierarchical tree of the elements and scripts on the page. It gives you a good overview of the page's content and its layout.

Double-clicking any element listed in the Document Outline window will highlight the corresponding markup for that element in the source view or the element display in the design view, depending on which view is currently open. This is very helpful in navigating a large, complex page.

DocumentOutline

More about Document Outline can be found here.

Anh Phan

SDET, Visual Web Developer

Tip# 77: Did you know… How to enable Page Level Tracing for your ASP.NET pages?

Enabling tracing at page level gives you a bunch of information that can be useful while debugging your application.Tracing helps understand which control uses more view state,  start/end of PreInit, start/end of Init, start/end of Render, etc. This information appears at the bottom of the page. By default page level tracing is disabled.

Tracing can be enabled at Page Level and also at Application Level

To enable Tracing at Page Level select DOCUMENT in Property grid and set it’s Trace property to true as shown below.

Enable trace for a page.

This will add Trace="true" in your page directive as shown below.

<%@ Page Language="VB"  Trace="true" %>

You can also add TraceMode attribute to specify if you want the trace messages to be SortedByTime or SortByCategory.

You can now run the page and see the details as follows:

Tracing Enabled

You can enable Application level tracing in the Web.config file of your application’s root. By doing this you will get trace information for all pages in your application. In this case you can set page level tracing to false if you do not want tracing information for particular pages.

<configuration> <system.web>

<trace enabled="true" requestLimit="40" localOnly="false"/>

</system.web></configuration>

Remember to turn it off before you move your application to production. Also, know that the page level trace setting overrides the trace setting at the application level.

Enjoy Tracing!

Reshmi Mangalore

SDET, Visual Web Developer

Tip #76: Did you know… How to hide a non-visual control in your designer?

Some times as you are building your web page, you may want to hide all the non-visual controls like Timer control so that the page looks close to how it would be rendered on your browser.

Our Designer can toggle between displaying and not displaying Non-visual controls using

 Ctrl+Shift+N

Display ASP.NET Non-visual controls turned on:

With Visual Aids turned on

Display ASP.NET Non-visual controls turned off:

NoControls

This option is also present under View menu.

View->Visual Aids –>ASP.NET Non-visual controls as shown below…

Menu

Enjoy!

Reshmi Mangalore

SDET| Visual Web Developer

Tip #75: Did you know…How to maintain scrollposition after post back?

When web pages are posted back to the server, by default user is returned to the top of the page. On a large web page, you might have a requirement to scroll down the user automatically to the last position on the page.

MaintainScrollPositionOnPostBack page property can be used to achieve this  in one of the following ways. 

  1. Application level: To set the property by default for all pages in the website, open web.config and add the attribute to the pages node.

    <pages maintainScrollPositionOnPostBack="true">

  2. Page Level: for a particular page, open the aspx and set the property

    <%@ Page MaintainScrollPositionOnPostback="true" ...

  3. Code level: to set the property programmatically

    Page.MaintainScrollPositionOnPostBack = true;

Hope this helps.

Deepak Verma
SDET | Visual Web Developer

Tip #74: Did you know…How to Add and Remove AJAX Extenders in Visual Studio 2008 Designer?

Tip#62 showed you how to add an AJAX Control Toolkit to your Toolbox.

Once you have the toolkit here is how you proceed:

1. Switch to Design View of the page and drag drop ScriptManager control from the AJAX Extensions tab of toolbox to the designer.

2. Drag drop an asp button control to the designer to which you would want to add the extender.

4. Select the button control and click on the Smart Tag. This will bring up the   

 Add Extender.. option.

Add Extender

5. Now click on Add Extender….This will bring up the Extender Wizard as shown below. Pick ConfirmButtonExtender and click Ok. Alternatively you can drag drop the ConfirmationButtonExtender from your toolbox on to the button control on your designer.

Confirmation

It is interesting to note that on adding an extender control, Visual Studio’s property grid displays the extender properties. Set the Confirm Text property for the extender to be      “Are you sure?”.

6. Run the page and see that on clicking the button, you get a confirmation box as shown below.

AreYouSure

7. To remove, select the control and bring up the Smart Tag and click on the Remove Extender option in the Smart Task Menu. This will bring up the Remove Extender dialog.

Click Remove and click Ok to remove the extender from your button control.

RemoveExtender

Enjoy!

Reshmi Mangalore

SDET, Visual Web Developer

Tip #73: Did you know... about IIS Search Engine Optimization (SEO) Toolkit Beta

IIS Search Engine Optimization (SEO) Toolkit Beta – is a free toolkit that helps Web developers, hosting providers, and server administrators improve their sites’ relevance in search results by recommending how to make them more search engine-friendly. The SEO Toolkit Beta is available for installation via the Microsoft Web Platform Installer 2.0 Beta.

The IIS SEO Toolkit can:

· Improve the volume and quality of traffic to Web site from search engines

· Control how search engines access and display Web content

· Inform search engines about locations that are available for indexing

The IIS SEO Toolkit includes three modules that integrate with IIS Manager:

· Site Analysis, which suggests changes that can help improve the volume and quality of traffic to your Web site from search engines;

· Robots Exclusion, which makes it easier to control and restrict the content that search engines index and display; and

· Sitemaps and Site Indexes, which can help inform search engines about locations that are available for indexing.

The IIS SEO Toolkit Beta can be installed with the Microsoft Web Platform Installer 2.0 Beta

· For more information, visit: http://www.iis.net/extensions/SEOToolkit

· For more information on the Microsoft Web Platform, visit www.microsoft.com/web

To follow Microsoft Web Platform on Twitter: www.twitter.com/mswebplatform

 

Thanks,

Deepak Verma
SDET | Visual Web Developer

Tip #72: Did you know... you can now manage Windows Server 2008 and Windows Server 2008 R2 from Windows 7


Last week, IIS Remote Manager was re-released to support Windows 7. Prior to this release, remote management was supported only on XP, Vista, Windows Server 2003 and Server 2008 (excluding Home Basic editions). Now, the users can install Remote Manager on Windows 7 Client to manage Server 2008 and Server 2008 R2 remotely.

Remote Manager is available for download on iis.net download center:
· IIS Manager for Remote Administration (x86)
· IIS Manager for Remote Administration (x64)

And also on microsoft.com:
· Internet Information Services (IIS) Manager

Finally, you can install IIS Remote Manager through Web Platform Installer:
clip_image001

Learn about Remote Manager:
· Remote Manager for Windows 2003, XP and Vista SP1

Kateryna Rohonyan
SDET, IIS Team

More Posts Next page »
Page view tracker