Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— 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?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.passwords  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 boxesrollovers calculations, validation of user inputs calculations 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)JavaScript Source  hiding proprietary code

5 Solution 2: Server Side Scripts use common gateway interface (CGI)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 applicationsVisual Web Developer Express 2008 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 languagesother 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)Visual Web Developer Express 2008Microsoft WebMatrix IIS or VWDX on your computer or free (for a while?) ASP.NET hostingfree (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 tags put: The time is: run code from that window

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

13 ASP.NET Output in HTML ASP inside a HTML tag The time is: use variable can come from server itself, or from client machine, or can be defined in code elsewhere in same or another ASP file The car is:

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 %> " > Size is

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

19 output.aspx Input from form: <% Dim strCustName as String strCustName = _ Request.QueryString("custName") Response.Write("last name is " & _ strCustName)%>

20 Using ASP.NET with Forms - 2 if have more than just one text field, must have a Submit button on form after development would use 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 &= " <font color=#" & colr(i) _ & ">" & colr(i) & " " 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


Download ppt "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."

Similar presentations


Ads by Google