Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Your First ASP_Net project part 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

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,
  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,
  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,
  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,
  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,
  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,
  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,
  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,
  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,
  11. 11. <ul><li>---------------------------------------------------------------- </li></ul><ul><li><% String Title = “My Page&quot;; %>  <%= Title %> </li></ul>(c) Biswadip Goswami,
  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,
  13. 13. (c) Biswadip Goswami,
  14. 14. (c) Biswadip Goswami,
  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,
  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,
  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,
  18. 18. (c) Biswadip Goswami,
  19. 19. (c) Biswadip Goswami,
  20. 20. (c) Biswadip Goswami,
  21. 21. (c) Biswadip Goswami,
  22. 22. (c) Biswadip Goswami,
  23. 23. (c) Biswadip Goswami,
  24. 24. (c) Biswadip Goswami,
  25. 25. (c) Biswadip Goswami,
  26. 26. (c) Biswadip Goswami,
  27. 27. (c) Biswadip Goswami,
  28. 28. (c) Biswadip Goswami,
  29. 29. (c) Biswadip Goswami,
  30. 30. (c) Biswadip Goswami,
  31. 31. (c) Biswadip Goswami,
  32. 32. (c) Biswadip Goswami,
  33. 33. (c) Biswadip Goswami,
  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: </li></ul>(c) Biswadip Goswami,