Please navigate to the bottom of the page for Table of Contents

Friday, May 27, 2011

ASP.NET @ Page directive

Every ASP.NET generally begins with the @ Page directive. This defines page-specific attributes used by the ASP.NET page parser and compiler and can be included only in .aspx files. By default, Visual Studio creates a page directive as shown below (when you use the default web application template):

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

This directive can be used only in Web Forms pages. You can include only one @ Page directive per .aspx file. Further, you can define only one Language attribute per @ Page directive, because only one language can be used per page.The Page directive is made of many attributes. Let’s review a few of the important ones:

Specifies a title for the page that is rendered within the HTML <title> tags in the response. The title can also be accessed programmatically as a property of the page.

Specifies the language used when compiling all inline rendering (<% %> and <%= %>) and code declaration blocks within the page. Values can represent any .NET Framework-supported language, including Visual Basic, C#, or JScript. Only one language can be used and specified per page.

Sets the path to the master page for the content page or nested master page. Supports relative and absolute paths.

Indicates whether the page's events are autowired. true if event autowiring is enabled; otherwise, false.

Specifies the name of the compiled file that contains the class associated with the page. This attribute is not used at run time. This attribute is used for Web application projects. The CodeFile attribute is used for Web site projects.

Defines a code-behind class for the page to inherit. This can be any class derived from the Page class. This attribute is used with the CodeFile attribute, which contains the path to the source file for the code-behind class. The Inherits attribute is case-sensitive when using C# as the page language, and case-insensitive when using Visual Basic as the page language.

If the Inherits attribute does not contain a namespace, ASP.NET checks whether the ClassName attribute contains a namespace. If so, ASP.NET attempts to load the class referenced in the Inherits attribute using the namespace of the ClassName attribute. (This assumes that the Inherits attribute and the ClassName attribute both use the same namespace.)

In addition to the attributes generated by default, you should also know about the following properties. They are a favorite of interviewers (they are either obscure, or ASP.NET 4 specific or they just like it).

Specifies the algorithm to use to generate ClientID values for controls. The default value is Predictable. The default value for controls is Inherit. Therefore, the default algorithm for controls in a page is determined by the ClientID setting of the page. A different default value can be set in the pages element of the Web.config file. For more information about the algorithms, see the ClientIDMode class.

Defines the HTTP content type of the response as a standard MIME type. Supports any valid HTTP content-type string.

Enables validation of events in postback and callback scenarios. true if events are being validated; otherwise, false. The default is true.

Page event validation reduces the risk of unauthorized postback requests and callbacks. When the enableEventValidation property is set to true, ASP.NET allows only the events that can be raised on the control during a postback request or callback. With this model, a control registers its events during rendering and then validates the events during the post-back or callback handling. All event-driven controls in ASP.NET use this feature by default.

It is strongly recommended that you do not disable event validation. Before disabling event validation, you should be sure that no postback could be constructed that would have an unintended effect on your application.

Defines session-state requirements for the page. true if session state is enabled; ReadOnly if session state can be read but not changed; otherwise, false. The default is true. These values are case-insensitive.

Specifies whether view state is maintained across page requests. This value is true if view state is maintained, or false if view state is not maintained. The default is true.


  1. I gone through your article, its really interesting. Dot net is most used programming language for creating highly dynamic desktop and web application. Dot net programming language has created massive revolution in software development industry. Best Dot Net Training

  2. Thank you so much..i have to really helpful for your sharing information..

    Information Training in Chennai | Oracle DBA Training in Chennai

  3. This comment has been removed by the author.


  4. Oracle DBA Training in Chennai
    Thanks for sharing this informative blog. I did Oracle DBA Certification in Greens Technology at Adyar. This is really useful for me to make a bright career..

  5. Excellent information with unique content and it is very useful to know about the information based on blogs. Hadoop Training in Chennai

  6. I found some useful information in your blog,it was awesome to read, thanks for sharing this great content to my vision, keep sharing..selenium Training in Chennai

  7. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.SAP Training in Chennai

  8. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.Nice article i was really impressed by seeing this article, it was very interesting and it is very useful for me.. Android Training in Chennai

  9. Wonderful tips, very helpful well explained. Your post is definitely incredible. I will refer this to my friend.SalesForce Training in Chennai

  10. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.Oracle DBA Training in Chennai

  11. This is really an awesome article. Thank you for sharing this.It is worth reading for everyone. Visit us:
    Oracle Training in Chennai

  12. fantastic presentation .We are charging very competitive in the market which helps to bring more oracle professionals into this market. may update this blog . Datastage Training In Chennai

  13. I have read your blog and I got very useful and knowledgeable information from your blog. It’s really a very nice article Spring training In Chennai

  14. i gain the knowledge of and industry oriented coaching available from greens technology chennai in Adyar may visit.Sharepoint Training In Chennai

  15. once again sharing this informative blog .It uses a graphical notation to construct data integration solutions and is available in various versions may visit greens technology chennai in adyaroracle dba training In Chennai

  16. i wondered keep share this sites .if anyone wants realtime training Greens technolog chennai in Adyar visit this blog..performance tuning training In Chennai

  17. Usually I am able to add links to other websites or pages within Informix Training In Chennai

  18. Thanks for the useful information that was provided, Get more ideas on Sql Server Dba Training In Chennai

  19. Thanks for sharing this informative blog. If anyone wants to get Struts Training In Chennai

  20. It was really a wonderful article and I was really impressed by reading this blog.Oracle sql plsql Training In Chennai

  21. This page is dedicated for our Greens Technologies Reviews by our students. Please give your reviews here, Qlikview Training In Chennai

  22. I like this post, and i learn new software product. thank to share with us Oracle Rac Training In Chennai

  23. This is very useful information. Thanks for sharing.Teradata Training In Chennai

  24. i gain the knowledge and industry oriented coaching available from greens technology chennai visit.Advanced oracle sql tuning Training In Chennai

  25. Very nice blogs!!! i have to learning for lot of information for this sites...
    android Training in Chennai | Oracle Training in Chennai

  26. Latest Govt Bank Jobs 2016

    This is awesome blog with smart content, Nice to see your post. Thanks...........

  27. Really awesome blog. Your blog is really useful for me.
    Thanks for sharing this informative blog. Keep update your blog.
    Oracle Training In Chennai

  28. I am reading ur post from the beginning, it was so interesting to read & i feel thanks to you for posting such a good blog, keep updates regularly.Best Hadoop Training Institute In Chennai

  29. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.
    Pega Training In Chennai

  30. Best Java Training Institute In ChennaiThis information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..

  31. What great post thanks for amazing sharing with lots of applications Company About Us

  32. thanks for sharing this information..
    Best SEO training in hyderabad all modules are clearly solved and practice with guide.seo training in hyderabadAnd clearly getting knowledge of seo.


  34. Great post....Thank you for posting the great content……I found it quiet interesting, hopefully you will keep posting such blogs…
    If you Want more seo course in chennai

  35. Excellent post. I like your blog. Thanks for sharing.

    ppc training in chennai

  36. Thank you so much..i have to really helpful for your sharing information..
    best informatica training institute

  37. This was actually what i was looking for, and i am glad to came here! Thank you very much

  38. We are Manufacturer of Fire Extinguisher in Delhi, Our Products are ISI Marked. Our Fire Squad Range of Products are designed to give you an authentic firefighting and security experience, all the times. Our Brands - Fire Squad, Fire Hunt and Elix Fire

    WEBSITE :-

    Service Name:-
    Fire Extinguisher Manufacturers in Delhi

  39. Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..

    iOS Training in Chennai

  40. Great post, This is very useful, Thanks for sharing and keep updating your post.
    Ladies Hostel in Kodambakkam

  41. On this give maneuver: tandum-heart and soul collapsing ward, crystal clear adi inside period of time of
    brand new unimportant; for any shining, kobe Bryant, initially the emperor incarnate elect; period is the
    abbreviation, on playoffs multiple better running footwear…
    My Web : we like to honor numerous other world wide web web pages around the web,
    Penangkal Petir Mueven though they arent linked to us, Penangkal Petir by linking to them.

  42. Thank you for this valuable information. I have got some important suggestions from it. I'm working in Brave Technologies Private Limited. We provides lowest price of ERP Software for our clients. Contact us on software Chennai

  43. The best thing is that your blog really informative thanks for your great information!
    erp providers in chennai

  44. Freelance Best Makeup & Hair Artist in Jaipur with huge experience and Specialization in Bridal and Wedding Makeup,Celebrity Makeup,Professional Makeup,Creative Makeup,Bollywood Makeup and Character Makeup in Delhi,Jaipur,Rajasthan. Natural Makeup that allows your skin to breath with a radiant glow and remains flawless throughout your special day.

    Best Makeup and Hairstyle in jaipur
    Fiza Makeup Academy in jaipur
    Best bridal makeup artist in jaipur(bollywood makeup,creative makeup,Airbrush makeup,character makeup)
    Make up and Hair kit
    Professional makeup artist course in jaipur
    Makeup and hairstyle tips
    Makeup and hair Images
    Makeup and hair tutorials
    Makeup and hair contract

  45. A pioneer Institute owned by industry professionals to impart vibrant, innovative and global education in the field of Hospitality to bridge the gap of 40 lakh job vacancies in the Hospitality sector. The Institute is contributing to the creation of knowledge and offer quality program to equip students with skills to face the global market concerted effort by dedicated faculties, providing best learning environment in fulfilling the ambition to become a Leading Institute in India.

    cha jaipur
    management college in jaipur
    management of hospitality administration jaipur
    cha management jaipur
    Best hotel college in jaipur
    Best management college in jaipur

  46. Great articles,first of all Thanks for writing such lovely Post! Earlier I thought that posts are the only most important thing on any blog.... Android Training in Chennai
    Selenium Training in Chennai
    Hadoop Training in Chennai

  47. The blog gave me idea about Page directive and the information about the attributes in page directive were very much useful. My sincere thanks for sharing this post
    Dot Net Training in Chennai

  48. Thank you so much for sharing this worth able content with us. The concept taken here will be useful for my future programs and i will surely implement them in my study. Keep blogging article like this.
    dot net training in chennai

  49. Thank you for sharing.If anyone want to become an Dotnet certified professional reach TIS Academy, which offers best Dot Net Training in Chennai with years of experienced professionals. For more details about courses..
    Hadoop Training in Chennai

  50. The blog gave me idea about the functional Programming and the features of functional programming are explained in an understandable manner Thanks for sharing this valuable post
    dotnet training in chennai