1 / 24

ASP.NET

ASP.NET. Dr. Ralph Westfall May, 2011. Web Development Problem. HTML designed to display static pages only interactive when user clicks links can’t provide animation except How Do I Make An Animated GIF ? can’t create custom pages for specific types of customers

brendy
Download Presentation

ASP.NET

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.NET Dr. Ralph Westfall May, 2011

  2. Web Development Problem • HTML designed to display static pages • only interactive when user clicks links • can’t provide animation • except How Do I Make An Animated GIF? • can’t create custom pages for specific types of customers • can’t use databases, spreadsheets, etc. • no security capabilities in HTML itself • except hiding passwords <input type="password" etc. • using very long/random directory/file names works a bit, but it's not HTML

  3. Solution 1: Client Side Scripts • JavaScript (dominant product) can do • animation, rollovers, message boxes • calculations, validation of user inputs • incorporate customized content into pages • e.g. based on day/time, user inputs, etc. • provide limited access to user’s system • system date, browser, plug-in information • set cookies (data for server for next visit)

  4. Client Side Scripts (continued) • what (client side) JavaScript can’t do • write meaningful data to files on the server (other than cookies) • provide adequate security for • access control (but JavaScript Source has some "hackish" scripts) • hiding proprietary code

  5. Solution 2: Server Side Scripts • use common gateway interface (CGI) • offer database & security capabilities • written in C, C++, Perl, Python, etc. • relatively difficult to program & maintain • use server resources relatively inefficiently • separate programs in addition to HTML • but this is probably an advantage

  6. Solution 3: "Classic" ASP • Microsoft's Active Server Pages released in 1996, works with Microsoft servers • Windows Server 2008 • free Visual Web Developer Express 2008 IDE includes a lightweight personal web server for developing ASP.NET applications • so does Visual Studio

  7. Solution 3: ASP (continued) • simple language • can go in same files as HTML code • provides many of the capabilities of CGI • uses server resources more efficiently than CGI • using ASP server extensions, can work with non-Microsoft servers, but …

  8. ASP.NET • major revision of ASP • can use different languages, not just VB.NET • VB.NET code looks more like Java than the VBScript used previously • .NET code is compiled into MSIL (Microsoft Intermediate Language) • MSIL is then interpreted into machine language that runs on the server

  9. ASP.NET: Many Languages • HTML (of course!) • Visual Basic.NET • can also use C# and J# with VWDX • .NET supports over 50 other languages • C++ and JScript (Microsoft's version of JavaScript) work with Visual Studio.NET • other (non Microsoft) languages can also work with Visual Studio.NET

  10. Tools To Develop & Use ASP.NET • a tool to create code • text editors: Notepad, TextPad, etc. • HTML authoring tools: Dreamweaver, FrontPage, etc. • Visual Studio.NET, Visual Web Developer Express 2008, Microsoft WebMatrix (2 free) • IIS or VWDX on your computer • or free (for a while?) ASP.NET hosting • web browser

  11. Simple ASP.NET • create ASP.NET project • Project>Add New Item>Web Form • view Source window and add .NET code to file • between <body> tags put: <% Response.Write("Hello, World!") %> <p>The time is: <% = Now() %></p> • run code from that window

  12. ASP.NET Coding within HTML • use <% at start, %> at end • on same line (inline) • <% = Time %> • or on multiple lines (block) • <% Response.Write("<P>Hello, World!") Response.Write 'cf. Console.Write • %>

  13. ASP.NET Output in HTML • ASP inside a HTML tag • <P>The time is: <% = Time %> • use <% = followed by a variable or a function that returns data, then %> • variable can come from server itself, or from client machine, or can be defined in code elsewhere in same or another ASP file • <% Dim strCar as String="Geo" %> <P>The car is: <% = strCar %>

  14. Generating ASP Output - 2 • ASP.NET code can write text and also data from ASP.NET variables • <% • Dim nAge as Integer = 22 • nAge += 10 • Response.Write("You will be" & nAge) • 'text variable • %>

  15. Generating ASP Output - 3 • can mix text, HTML, and ASP.NET variables in code • this includes using ASP to write HTML tags, in addition to writing variables and text

  16. fontsize.aspx <% Dim intI as Integer For intI = 1 to 7 %> <!-HTML inside ASP loop-> <font size = "<% = intI %>" > Size is <% = intI %> </font><br/> <% Next %> <!--what will you see from this? Notes about " "-->

  17. Using ASP.NET with Forms • use HTML or ASP page to create a form • be sure all form fields have id = "[ ]" and also name = "[ ]" 'same as for id= • use an ASP.NET page to process inputs • action attribute in form has name of an ASP.NET file, and use Input (Submit) button • form field values accessible to ASP as Request.QueryString("[form field name]")

  18. input.html <form method="get" action="output.aspx"> Last Name <input type="text" name="custName" id="custName"> </form> <!--need to refresh?-->

  19. output.aspx • <!-- Visual Studio generated headers--> • <html><body> • Input from form: • <% • Dim strCustName as String strCustName = _ Request.QueryString("custName") • Response.Write("last name is " & _ strCustName)%> </body></html>

  20. Using ASP.NET with Forms - 2 • if have more than just one text field, must have a Submit button on form <input type="submit" [etc.]> • after development would use • <form method="post"[etc.]> • when using post, also need to change every Request.QueryString to Request.Form in the ASP page identified by the action

  21. Another Demonstration • Create: Web Site… ASP.NET Web Site • add a Label to Default.aspx designer and expand it vertically and horizontally to occupy 25% of the screen (could make Height="[]px" and Width="[]px" • double click the screen (outside of the label) to start a Page_Load Sub • paste code on following page into Sub

  22. VB.NET Web Code Dim i As Integer Dim colr() As String = {"000000", "333300", _"666600", "999900", "cccc00", "ffff00"} Dim output As String = "" For i = 0 To 5 output &= "<h1><font color=#" & colr(i) _ & ">" & colr(i) & "</font></h1>" Next Label1.Text = output

  23. Run Code • click Start • (first time) modify the web.config…>OK • view code and then make changes as necessary

  24. CIS 451 ASP.NET • ASP Code Samples

More Related