1 / 31

ASP/ASP.NET: Tricks and Tips

ASP/ASP.NET: Tricks and Tips. How to get Microsoft’s Programming Language to work for you By Wade Tripp Park University wtripp@mail.park.edu. Disclaimer.

balin
Download Presentation

ASP/ASP.NET: Tricks and Tips

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ASP/ASP.NET: Tricks and Tips How to get Microsoft’s Programming Language to work for you By Wade Tripp Park University wtripp@mail.park.edu

  2. Disclaimer I am not an expert in all the details, just giving a general overview of how it works, and there are over a dozen ways how to do things, with half of them working.

  3. Who are YOU?

  4. History of ASP (abbreviated) • VBScript • Client Side • Possible for all sorts of problems, intentional or not • Required the client to have IE installed

  5. History of ASP (abbreviated) • ASP • Server Side Scripting • Browser independent • Required special server software • but….. • Very much interpreted and scripting • Created many bad programming habits

  6. History of ASP (abbreviated) • ASP.NET • Server Side Scripting • Able to program in many languages • Permits good programming practice • but…. • Steep learning curve

  7. How ASP works • Browser requests a web page • Web server gets request and loads file from hard drive • Web server sends the file to asp.dll to process • Returns to the browser the processed page

  8. How ASP.NET works (interpreted) • Browser requests a web page • Web server gets request and loads the file from hard drive • Web server sends the file to aspnet_isapi.dll to process • Returns to the browser the processed page

  9. How ASP.NET works (compiled) • Browser requests a web page • Web server gets request and loads dll from hard drive • Web server sends the file to aspnet_isapi.dll to process • Returns to the browser the processed page • The code does not have to be on the server

  10. ASP Quick and easy to use and do Easy to modify and tweak Uses the very basics and forgiving ASP.NET (Interpreted) Increased flexibility No need to code everything from scratch Memory of events Still can get confusing for large projects ASP.NET (Compiled) Most flexible Hardest to understand Easy to get good programming standards Differences between ASP

  11. Simple and quick – ASP Ex – Date modified, Alert Message Differences between ASP Repeated on several pages – ASP.NET Interpreted Ex – Announcement on several web pages Advanced Application – ASP.NET Compiled Ex – Registration form

  12. ASP/ASP.NET handles the appearance, input/output of a web page The Code Behind focuses on the thinking and language “Code Behind” can happen in a web page itself and does not have to be in a .vb or .cs file Any language can use in theory, VB and C# are the ones Microsoft has preconnected in Visual Studio, but almost any can be used. Java is not used for various legal reasons. Getting down to code

  13. To simply display stuff ( traditionally used in ASP ) you use <% %> <% Response.Write ("Hello World") %> <% = 2 + 2 %> ASP is forgiving, so if you miss the ( ) in Response.Write, it has variant type and other items. But if you save it as .aspx it may not work. Simple Displaying Stuff

  14. No, but they are so close that most of the time you can just do minor changes and tweaks going from asp to aspx . Several things are required (Declaration of variables) The big change with CDONTS. The method for sending out mail was changed from ASP to ASP.NET IIS 5 to IIS 6 for various reasons [Security being the main one] Is .asp the same as .aspx

  15. There are two ways to get information. QueryString/Get Information is sent via the URL Form/Post Information sent in the page QueryString vs. Forms

  16. <form method="GET"> It appears in the URL .. /index.asp?Sample=test&B1=Submit The ? Marks the end of the URL and the rest are variables Items are recoded for valid characters (make spaces into +, & turned into %26 and other items) Advantage jump directly to section, performing items QueryString

  17. Easily find the information via History and guessable test.asp?ID=45 Limited on how much information can be passed. Dependant on browser of 1000, 2000+ characters QueryString Disadvantages

  18. What is normally used with web pages <form method="POST"> Better to make things go better and organized, less chance of being reviewed Form

  19. <% Dim intNumber as integer intNumber = Request.QueryString(“Test”) intNumber = Request.Form(“Test”) Response.Write (intNumber) %> Actually using it

  20. Based on ideas of Jan Lukasiewicz Standard documenting is putting type in front of name intName – Integer strName – String bolName – Boolean values TIP - Polish Notation

  21. Also good for ASP txtName – Textbox lblName – Label panName – Panel lstName – List …. It keeps you organized TIP - Polish Notation

  22. <asp:TextBox id="TextBox1" runat="server"></asp:TextBox> When it is transformed by the compiler it becomes <input name="TextBox1" type="text" id="TextBox1" /> What all happened? ASP.NET is transformed into HTML Basics of ASP.Net

  23. Information is stored in a hidden view, called the Viewstate It sends and organizes the information for each variable and items <input type="hidden" name="__VIEWSTATE" value="dDwxMKA0NDg0NTY3Ozs+LbpQGFDDxjwkOEzOioQydd7xkTg=" /> The information is stored for all server objects How does information get stored

  24. Each ASP.NET item requires resources Don’t use labels for standard items. Why? Because it takes extra resources and time to download TIP – Don’t make everything label

  25. Each ASP.NET item requires resources Don’t use labels for standard items. Why? Because it takes extra resources and time to download TIP – Don’t make everything label

  26. Information can be handled Session Application Variable Value of ASP Object Hidden Field Passed Variable in Form TRICKS – Storing information

  27. Can connect to database via connection with SQL, Access, Informix, etc… anything that permits ODBC Warning – Access can cause problems with older web servers TRICKS – Database Reading

  28. Permits scripting to run after an item has been altered Requires Javascript TRICKS – AutoPostback

  29. Lets a user check to make sure a field is probably filled out Normally uses Javascript to validate There are a few ways around it (disable Javascript) TRICKS – Validation

  30. Permits forms not to blink by using ‘IFRAME’ TRICKS – Smart Navigation

  31. Used to find what variables and objects are used Remove the Me. after you go though the form TRICKS – ME - ASP

More Related