tags:

views:

40

answers:

3

I am new to asp.net, I want to define #Region in my .cs page file. Is it possible to that in web pages. I know it can be done in winforms.

+2  A: 

No, you can't define #regions in webforms (in the ASPX file), but you can collapse tags very easily in visual studio, as long as your markup is properly defined.

Dave Markle
@Dave Markle - You _can_ define `#regions` in code behind files.
Oded
He talks about "web pages" which I took to mean ASPX files, and then mentions .cs files, where the answer is somewhat obvious... Seemed like a self-contradictory question the way I read it...
Dave Markle
+1  A: 

You can define #region tags in your code behind files the same way you can in any .cs file - it makes no difference if they are in a web project or any other project.

You can't define them in the .aspx page.

In your .cs code behind file:

#region "Name of region"

   // Code comes here

#endregion
Oded
can you please give me the syntax to do that.
vaibhav
@vaibhav - It is the _same_ syntax as any #region in C#.
Oded
A: 
  #region Description of the code within this region
  protected void Page_Load(object sender, EventArgs e)
  {

  }
  #endregion

I'm using Visual Studio 2008 SP1 and it's working. Which version are you using?

Ismail