Friday, July 27, 2007

Visual Studio 2008 Beta 2 released.

Find it using this link: Visual Studio 2008 Beta 2.

Rob Caron has an easier way to download Visual Studio 2008 Beta 2.

Looking for an easier way to download those huge Visual Studio 2008 Beta 2 files? Go grab the Microsoft Secure Content Downloader from Microsoft Research.

Unfortunately it not install over Beta 1, Beta 1 has to be uninstalled. But it does have a go-live license, which means it can be used in production It also means it very close to being feature complete. I just can't wait for it to be released.

Make sure you read the Installation notes section of Scott Guthrie's blog post. Also Daniel Moth blogs his Visual Studio 2008 installation experience.

Thursday, July 26, 2007

Nested GridViews and Hiding

Often we use nested GridView controls, so that individual rows in the master GridView can display a nested GridView in one of its columns. This is especially useful to show master/details relationships. However sometimes we might want to show the nested GridView only for the selected row. This post discusses one way to do it.

Prerequisites

Understanding of the GridView control.
Understanding of TemplateField class.
Understanding of SqlDataSource class.

If you are looking to understand how to create nested GridView controls, there is an excellent article on MSDN titled: Walkthrough: Creating a Nested GridView Control

Listed below is the source code for my aspx page. I've kept only the essential parts of the code:


   1: <asp:SqlDataSource ID="masterDataSource" .../>
   2: <asp:SqlDataSource ID="nestedDataSource" ... />
   3: <asp:GridView ID="masterGrid" OnSelectedIndexChanged="masterGrid_SelectedIndexChanged" ...>
   4:     <Columns>
   5:         <asp:BoundField ... />
   6:         <asp:BoundField ... />
   7:         <asp:TemplateField>
   8:             <ItemTemplate>
   9:                 <asp:GridView ID="nestedGrid" DataSourceID="nestedDataSource" Visible="false">
  10:                     <Columns>
  11:                         <asp:BoundField ... />
  12:                     </Columns>                        
  13:                 </asp:GridView>
  14:             </ItemTemplate>
  15:         </asp:TemplateField>
  16:     </Columns>
  17: </asp:GridView>


Line 1: SqlDataSource called masterDataSource which will be used to populate the master GridView (masterGrid, line 3)
Line 2: SqlDataSource called nestedDataSource which will be used to populate the nested GridView (nestedGrid, line 9)
Line 3: Master GridView called masterGrid. Uses masterDataSource as the data source. Specifies masterGrid_SelectedIndexChanged as the method handler for SelectedIndexChanged event.
Line 9: Nested GridView called nestedGrid. Uses masterDataSource as the data source. Insert as a TemplateField.

Listed below is the source code for the masterGrid_SelectedIndexChanged event:

   1: protected void masterGrid_SelectedIndexChanged(object sender, EventArgs e)
   2: {
   3:     foreach (GridViewRow row in masterGrid.Rows)
   4:     {
   5:         row.FindControl("nestedGrid").Visible = false;
   6:     }
   7:     //Retrieve the data to be filled in the nestedGrid for the selected row
   8:     nestedDataSource.SelectParameters[0].DefaultValue = masterGrid.SelectedDataKey[0].ToString();
   9:     nestedDataSource.DataBind();            
  10:     //Set the visibility of for the nestedGrid for the selected row
  11:     masterGrid.SelectedRow.FindControl("nestedGrid").Visible = true;            
  12: }

Line 3-6: I hide all the nestedGrid controls.
Line 11: For only the selected row I show the nestedGrid. It was as simple as that!.




Tuesday, July 17, 2007

Multi-targeting FAQ

What is multi-targeting?

Starting with Visual Studio 2008 developers will be able to target multiple versions of the .NET Framework using the same version of Visual studio. Developers will be able to start taking advantage of the new features Visual Studio provides without having to always upgrade their existing projects and deployed applications to use a new version of the .NET Framework library.

Isn't this currently possible to target v1.1 using Visual Studio 2005?

Currently, applications can be built to target the 1.1 Framework with Visual Studio 2005 using MSBee; however, the setup and compilation can be tricky at best. In Visual Studio 2008, Microsoft looks to bring the process of targeting version 2.0 and above of the .NET Framework directly into the IDE

What kind of support does Visual Studio 2008 provide?

  • Creating new projects: Automatically filter and show only those project templates that are available for the currently selected version when creating a new project.
  • Adding references: The assembly reference picker dialog will automatically gray out assemblies that are not available for the currently selected version.
  • Config files: The IDE will use the schema of the currently selected version for the configuration files.
  • Controls: Only those controls that are available for the currently selected version will be shown in the toolbox.
  • Compiler settings: Compiler settings are automatically set as per the currently selected version.

Can an existing project be upgraded?

Yes. The targeted version can be changed from the project's properties page. Once the Target Framework is changed, Visual Studio will update the project with the new assemblies, controls, and compiler settings.

Are all versions supported?

Unfortunately the VS 2008 multi-targeting support only works with .NET 2.0, .NET 3.0 and .NET 3.5 - and not against older versions of the framework.  The reason for this is that there were significant CLR engine changes between .NET 1.x and 2.x that make debugging very difficult to support.  In the end the costing of the work to support that was so large and impacted so many parts of Visual Studio that we weren't able to add 1.1 support in this release.

What about future versions of Visual Studio and .NET framework? Will multi-targeting be supported?

Yes. Future versions will follow the same model.

What about older projects that are opened in Visual Studio 2008?

The user will be presented with an option to run a conversion utility which will allow the user to upgrade to a newer version. (Pretty similar to what happens in Visual Studio 2005)

Can I use Visual Studio 2008 and Visual Studio 2005 interchangeably for a .NET 2.0 project?

Visual Studio 2008 makes changes to the solution file that prevents the project from being loaded in Visual Studio 2005. Other than the changed to the solution file, no changes are made to any other files.

Will multi-targeting work with ASP.NET and AJAX?

Applications built using ASP.NET AJAX 1.0 running on ASP.NET 2.0 will work inside VS 2008 (you'd just target the .NET 2.0 runtime).  You can also then easily upgrade it to .NET 3.5.

Will ASP.NET 2.0 projects developed in Visual Studio 2008? run within existing ASP.NET 2.0 app pools ?

Yes.

What versions of Visual Studio 2008 will support multi-targeting?

Multi-targeting will be supported with both Visual Studio as well as Visual Web Developer Express and the other Express products.

Technorati Tags:

Monday, July 16, 2007

Visual Studio 2008 to be released in 2007

Are per the blog posts found here and here, Visual Studio 2008 will ship before the end of this year. Also it will be launched along with Windows Server 2008 and Microsoft SQL Server 2008 at an event here in Los Angeles on 27 February 2008.

As per Scott Guthrie

We typically release products several weeks/months before we "launch" them. You'll be able to buy the final release of VS 2008 and start using it before we hold the launch event.

Wednesday, July 11, 2007

Web service time out in Visual Studio 2005 debug mode

We use a web service to standardize US addresses (convert Av to Ave., LA to Los Angeles etc). The web service has been around since a long time and is used by a lot of applications written in .NET 1.1. But today when using it in Visual Studio 2005 I noticed something. It threw a WebException.Timeout  exception every time I invoked it while I was debugging. It worked fine when invoked while the application was running normally, just not while being debugged. That's when a colleague asked me to add the following lines to my machine.config file, after which every worked fine.

<system.diagnostics>
<switches>
<add name="Remote.Disable" value="1"/>
</switches>
</system.diagnostics>



Symptoms: A web service method runs fine when invoked normally, but throws a exception when it is invoked from Visual Studio 2005 in debug mode. The web service method runs fine when invoked from Visual Studio 2003 in debug mode.


Cause:  It seems that the Visual Studio 2005 debugger some data to each outgoing request which is used for debugging. However, this data destroys the well-formedness of the request.

Tuesday, July 3, 2007

Expresso - The best regular expression tool

One of the projects I am working on involves screen scraping information off various web sites. Shortly after I started, I quickly learnt that any attempts towards serious screen scraping will required the use of regular expressions to detect patterns in the HTML source. And so began my (short lived) search for a tool to help me build and test regular expressions - thanks to Expresso 3.0 by Ultrapico.

Expresso is by far the best free regular expression tool I have used to date. It has the following features that I consider very important in a regular expression tool (and much, much more)

  1. Expression builder (Expresso enables you to create regular expressions without having to remember an arcane syntax.)
  2. Expression library (library of common and frequently used expressions) and the ability add to it.
  3. Expression analyzer (Complex regular expressions can be notoriously obtuse to read)
  4. Expression validator
  5. Grouping of matches showing captured groups.

 But the wow factor really kicked in when I saw that Expresso has many more features like exporting results, partial matching, performance testing, character class subtraction etc.

Subscribe to my feed in your favorite feed reader