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:


Title
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.


Language
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.


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


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


CodeBehind
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.


Inherits
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).


ClientIDMode
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.


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


EnableEventValidation
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.


EnableSessionState
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.


EnableViewState
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.

56 comments:

  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

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

    Information Training in Chennai | Oracle DBA Training in Chennai

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete

  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..

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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

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

    ReplyDelete
  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

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

    ReplyDelete
  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

    ReplyDelete
  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

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

    ReplyDelete
  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

    ReplyDelete
  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

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

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

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

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

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

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

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

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

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

    ReplyDelete
  26. Latest Govt Bank Jobs 2016

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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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..

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

    ReplyDelete
  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.

    ReplyDelete
  33. WONDERFUL ARTICLE, REALLY GOOD INFORMATION AND NICE EXPLANATION...KEEP IT UP.

    ReplyDelete
  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

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

    ppc training in chennai

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

    ReplyDelete
  37. This was actually what i was looking for, and i am glad to came here! Thank you very much
    angelfire
    wikidot
    mywapblog
    page
    inube
    tumblr

    ReplyDelete
  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 :-

    www.varshafireengineers.com

    Service Name:-
    Fire Extinguisher Manufacturers in Delhi

    ReplyDelete