Regions in webforms asp.net

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

+2


a source to share


3 answers


You can define tags #region

in your code behind files just like you can in any file .cs

- it doesn't matter if they are in a web project or any other project.

You cannot define them on the page .aspx

.



In the code .cs

behind the file:

#region "Name of region"

   // Code comes here

#endregion

      

+2


a source


No, you cannot define # scopes in webforms (in an ASPX file), but you can easily collapse tags in visual studio if your markup is correctly defined.



+2


a source


  #region Description of the code within this region
  protected void Page_Load(object sender, EventArgs e)
  {

  }
  #endregion

      

I am using Visual Studio 2008 SP1 and it works. Which version are you using?

+1


a source







All Articles