Your First ASP_Net project part 1

1,595
-1

Published on

This slide show may guide you through various steps to build your first website using ASP.Net technology.

Published in: Education, Technology
1 Comment
5 Likes
Statistics
Notes
No Downloads
Views
Total Views
1,595
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
1
Likes
5
Embeds 0
No embeds

No notes for slide

Your First ASP_Net project part 1

  1. 1. Your First ASP.Net Project – Part 1 By: Biswadip Goswami (c) Biswadip Goswami, [email_address]
  2. 2. What’s in a page ! <ul><li>Fundamentally an ASP.NET page is just the same as an HTML page. </li></ul><ul><li>Code in an HTML Page: </li></ul><ul><li><html> </li></ul><ul><li><body bgcolor=&quot;yellow&quot;> </li></ul><ul><li><center> </li></ul><ul><li><h2>Hello World!</h2> </li></ul><ul><li></center> </li></ul><ul><li></body> </li></ul><ul><li></html> </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  3. 3. <ul><li>Important aspects of developing a ‘Page’ in ASP.Net </li></ul><ul><li>Page structure </li></ul><ul><li>View state </li></ul><ul><li>Namespaces </li></ul><ul><li>Directives </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  4. 4. Elements of a Page <ul><li>Directives </li></ul><ul><li>Code declaration blocks </li></ul><ul><li>Code render blocks </li></ul><ul><li>ASP.NET server controls </li></ul><ul><li>Server-side comments </li></ul><ul><li>Server-side include directives </li></ul><ul><li>Literal text and HTML tags </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  5. 5. <ul><li>Presentational elements within the page are contained within the <body> tag, while application logic or code can be placed inside <script> tags. </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  6. 6. <ul><li>Directives control how a page is compiled, specify settings when navigating between pages, aid in debugging (error-fixing), and allow you to import classes to use within your page's code. Directives start with the sequence <%@, followed by the directive name, plus any attributes and their corresponding values, then end with %>.  </li></ul><ul><li>The two most important are the Import and Page directives.  </li></ul><ul><li>e.g. <%@ Page Language=&quot;C#&quot; %> </li></ul><ul><li>  The value provided for this attribute, in quotes, specifies that we're using either VB.NET or C#. NET. </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  7. 7. <ul><li>Code-behind pages - they let us separate our application logic from an ASP.NET page's HTML presentation code. </li></ul><ul><li>If there is no code behind pages, code declaration blocks  must be used to contain all the application logic of your ASP.NET page. </li></ul><ul><li>We place the code inside  < script >  tags. </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  8. 8. <ul><li>Code block in C# : </li></ul><ul><li><script runat=&quot;server&quot;>  void mySub() {   // Code here  }  </script> </li></ul><ul><li>---------------------------------------------------------------- </li></ul><ul><li><script runat=&quot;server&quot; language=&quot;C#&quot;> </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  9. 9. <ul><li>Code declaration blocks are generally placed inside the <head>  tag of your ASP.NET page. </li></ul><ul><li>If we don't specify a language within the code declaration block, the ASP.NET page will use the language provided by the language attribute of the Page directive. </li></ul><ul><li>The second attribute available is src, which lets you specify an external code file to use within your ASP.NET page: </li></ul><ul><li>------------------------------------------------------------------------------- </li></ul><ul><li><script runat=&quot;server&quot; language=&quot;C#&quot; src=&quot;mycodefile.cs&quot;> </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  10. 10. <ul><li>Code render blocks  is used to define inline code or inline expressions that execute when a page is rendered, and you may recognize these blocks from traditional ASP. Code within a code render block is executed immediately as it is encountered, usually when the page is loaded or rendered for the first time, and every time the page is loaded subsequently. </li></ul><ul><li>Inline code render blocks execute one or more statements and are placed directly inside a page's HTML within <% and %> characters. </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  11. 11. <ul><li>---------------------------------------------------------------- </li></ul><ul><li><% String Title = “My Page&quot;; %>  <%= Title %> </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  12. 12. <ul><li>At the heart of ASP.NET pages lies the  server controls , which represent dynamic elements that your users can interact with. There are four basic types of server control: ASP.NET controls, HTML controls, validation controls, and user controls. </li></ul><ul><li>All ASP.NET controls must reside within a <form runat=&quot;server&quot;> tag in order to function correctly. </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  13. 13. (c) Biswadip Goswami, biswadip@cognobytes.com
  14. 14. (c) Biswadip Goswami, biswadip@cognobytes.com
  15. 15. <ul><li>Server-side comments  allow you to include, within the page, comments or notes that will not be processed by ASP.NET.  </li></ul><ul><li>--------------------------------------------------------------------- </li></ul><ul><li><%--   <button runat=&quot;server&quot; id=&quot;myButton&quot; onServerClick=&quot;Click&quot;>Click Me</button>  <% Title = &quot;New Title&quot; %>  </li></ul><ul><li>--%> </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  16. 16. <ul><li>View State </li></ul><ul><li><html>  <head>  <title>Sample Page using C#</title>  <script runat=&quot;server&quot; language=&quot;C#&quot;>  void Click(Object s, EventArgs e) {   lblMessage.Text = txtName.Text;  }  </script>  </head>  <body>  <form runat=&quot;server&quot;>   <asp:TextBox id=&quot;txtName&quot; runat=&quot;server&quot; />   <asp:Button id=&quot;btnSubmit&quot; Text=&quot;Click Me&quot; OnClick=&quot;Click&quot;       runat=&quot;server&quot; />   <asp:Label id=&quot;lblMessage&quot; runat=&quot;server&quot; />  </form>  </body>  </html> </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  17. 17. <ul><li>ASP.NET pages maintain view state by encrypting the data within a hidden form field.  </li></ul><ul><li>View state is enabled for every page by default. If you do not intend to use view state, you can turn it off, which will result in a slight performance gain in your pages. </li></ul><ul><li>--------------------------------------------------------------------- </li></ul><ul><li><%@ Page EnableViewState=&quot;False&quot; %> </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com
  18. 18. (c) Biswadip Goswami, biswadip@cognobytes.com
  19. 19. (c) Biswadip Goswami, biswadip@cognobytes.com
  20. 20. (c) Biswadip Goswami, biswadip@cognobytes.com
  21. 21. (c) Biswadip Goswami, biswadip@cognobytes.com
  22. 22. (c) Biswadip Goswami, biswadip@cognobytes.com
  23. 23. (c) Biswadip Goswami, biswadip@cognobytes.com
  24. 24. (c) Biswadip Goswami, biswadip@cognobytes.com
  25. 25. (c) Biswadip Goswami, biswadip@cognobytes.com
  26. 26. (c) Biswadip Goswami, biswadip@cognobytes.com
  27. 27. (c) Biswadip Goswami, biswadip@cognobytes.com
  28. 28. (c) Biswadip Goswami, biswadip@cognobytes.com
  29. 29. (c) Biswadip Goswami, biswadip@cognobytes.com
  30. 30. (c) Biswadip Goswami, biswadip@cognobytes.com
  31. 31. (c) Biswadip Goswami, biswadip@cognobytes.com
  32. 32. (c) Biswadip Goswami, biswadip@cognobytes.com
  33. 33. (c) Biswadip Goswami, biswadip@cognobytes.com
  34. 34. Thank You ! <ul><li>For assistance with your ASP.Net requirements contact: </li></ul><ul><li>Biswadip Goswami </li></ul><ul><li>Primary e-mail: [email_address] </li></ul><ul><li>Alt e-mail: [email_address] </li></ul><ul><li>Webpage: http://people.cognobytes.com/biswadip </li></ul>(c) Biswadip Goswami, biswadip@cognobytes.com

×