09/26/10

Permalink 06:22:03 pm, by dave Email , 216 words, 9425 views   English (US)
Categories: ASP.NET

Using regions in ASP.NET

I have been doing some ASP.NET coding recently I was looking for a way to use the #region directive in Visual Studio 2010 to manage sections of the aspx files. I really wanted to be able to collapse and expand the region sections to make it easier to navigate the files. I searched for some solutions, but did not find anything. What I did find was a post about using #regions in javascript files. The solution was written for Visual Studio 2008 and with a little [very little tweaking], I was able to use the same solution for my need. I started with this post and made the following changes in order to get it to work for me.
First I changed these two lines from:

Code:

Const REGION_START As String = "//#region"
Const REGION_END As String = "//#endregion"

TO:

Code:

Const REGION_START As String = "<%--#region"
Const REGION_END As String = "#endregion--%>"

Then I changed the macro mapping from Ctrl+M Ctrl+E to Ctrl+A Ctrl+P.

Other than these two changes, I followed the instructions from this post verbatim.

Now I can add region tags to my ASP.NET files, run the macro [each time I load the file - including after a debugging session] and collapse and expand those sections as needed.

Cheers,
Dave

Leave a commentTrackback (0)

Did you like this post? If so, Share it!  del.icio.us digg reddit slashdot this article Facebook Twitter MySpace Email

Development

A place to keep track of development ideas, finds, and fixes

Search

Follow Me:

Categories

Archives

Misc

Who's Online?

  • Guest Users: 1

powered by b2evolution free blog software