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
2010-05-13 09:38:17
@Dave Markle - You _can_ define `#regions` in code behind files.
Oded
2010-05-13 09:41:33
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
2010-05-13 09:59:06
+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
2010-05-13 09:40:04
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
2010-05-13 09:43:34