Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Add REGION in Visual Studio in aspx Files

I use asp.net with code behind and c#.

So I have two file for every .aspx page in VS 2010.

In .aspx.cs page I am able to add regions in my code using:

#region Name Region
#endregion

My questions:

  • How to do it in file .aspx? #region seems working only in .cs file.
  • Do you know any other useful tag to help me to organize better my code both for .aspx and .cs file?
  • Do you know the keyboard shortcuts to expand or collapse all my region in my code?

Thanks for your help.

like image 576
GibboK Avatar asked Mar 09 '11 08:03

GibboK


People also ask

How do I add a region in Cshtml?

cshtml code editor, type region , then press Tab key. This implements #region snippet code like below: <! -- #region name --> //Your html or cshtml codes <!

How do I add ASPX page to Visual Studio?

Select the Visual C# -> Web templates group on the left. Then, select Web Form from the middle list and name it FirstWebPage. aspx. Click Add to add the web page to your project.

How do I add a region in Visual Studio?

Select some piece of code and use (ctrl+r, ctrl+e), type your region name and press enter. Or select some piece of code, press F1 and type "Move into #region".


1 Answers

Do you know the keyboard shortcuts to expand or collapse all my region in my code?

Here are some key chords for you.

Ctrl-M Ctrl-O will collapse all the regions in the opened document (or the highlighted section).

Ctrl-M Ctrl-M will collapse or open the collapsible section the cursor is on.

Ctrl-M Ctrl-L will collapse or open everything.

Now here is one i use frequently, especially in javascript files: highlight some code, then press Ctrl-M Ctrl-H to hide it, which will produce a little expander +- next to the collapsed code. Press Ctrl-M Ctrl-O to expand it again.

Also see this blog post by Scott Guthrie which details some posters you can download with lots of the VS shortcut key combinations on them.

like image 88
slugster Avatar answered Oct 14 '22 02:10

slugster