Cis 451 introduction to asp net
This presentation is the property of its rightful owner.
Sponsored Links
1 / 26

CIS 451: Introduction to ASP.NET PowerPoint PPT Presentation


  • 74 Views
  • Uploaded on
  • Presentation posted in: General

CIS 451: Introduction to ASP.NET. Dr. Ralph D. Westfall January, 2009. Web Development Problem. HTML designed to display static pages only interactive when user clicks links can’t provide animation except animated GIFs can’t create custom pages for specific types of customers

Download Presentation

CIS 451: Introduction to 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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Cis 451 introduction to asp net

CIS 451:Introduction to ASP.NET

Dr. Ralph D. Westfall

January, 2009


Web development problem

Web Development Problem

  • HTML designed to display static pages

    • only interactive when user clicks links

      • can’t provide animation

        • except animated GIFs

      • 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 long directory/file names works somewhat, but it's not HTML


Solution 1 client side scripts

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)


Client side scripts continued

Client Side Scripts (continued)

  • what (client side) JavaScript can’t do

    • connect with databases, and possibly other applications on the server

    • provide meaningful security for

      • access control (but JavaScript Source has some "hackish" scripts)

      • hiding proprietary code if it's in the HTML file or user has a tool to find it (e.g., Web Developer add-on for Firefox)


Solution 2 server side scripts

Solution 2: Server Side Scripts

  • use common gateway interface (CGI)

  • offer database & security capabilities

  • written in C, C++, Perl, etc.

    • relatively difficult to program & maintain

  • use server resources relatively inefficiently

  • separate programs in addition to HTML

    • but this is probably an advantage


Solution 3 asp

Solution 3: ASP

  • Active Server Pages

  • released by Microsoft 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


Solution 3 asp continued

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 …


Asp net

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


Asp net many languages

ASP.NET: Many Languages

  • HTML (of course!)

  • Visual Basic.NET

  • can also use C# and J# with VWDX

  • .NET supports over 30 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


Tools to develop use asp net

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, Web Matrix or Visual Web Developer Express 2008 (free!)

  • IIS or VWDX on your computer

    • or free 14-day ASP.NET hosting

  • web browser


Creating an asp net page

Creating an ASP.NET Page

  • create an HTML document

  • add ASP code in appropriate places

  • save with extension of .aspx

  • if don't have local server on computer, upload to a remote ASP.NET server

    • Cal Poly Intranet server won't run ASP

  • view in browser (file can be on local machine with server or remote server)


Simple asp net page not visual studio

Simple ASP.NET Page (not Visual Studio)

  • create a document with HTML code

  • add .NET code within HTML (inline)

    • at top, need

      <%@ Page Language="VB" %>

  • save with extension of .aspx

  • upload to remote server (if don't have Web Matrix or IIS) or paste into VS

  • view in browser


Hello aspx

hello.aspx

<%@ Page Language="VB" %>

<html>

<body> <!-- paste below </form> tag-->

<%

Response.Write("<P>Hello, world!")

%>

<P>The time is: <% = Now() %>

</body>

</html> <!-- View Source in browser -->


Asp net coding within html

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 'like VB.NET Debug.Write

    • %>


Asp net output in html

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


Generating asp output 2

Generating ASP Output - 2

  • ASP.NET code can write text and also data from ASP.NET variables

    • hit counter example

    • <%

    • nHits = nHits + 1

    • Response.Write "Hits = " & nHits

      • 'text variable

  • %>


  • Generating asp output 3

    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


    Fontsize aspx

    fontsize.aspx

    • <%

    • Dim intI as Integer

    • For intI = 1 to 7

    • %> <!-HTML inside ASP loop->

    • <font size = <% = intI %> >

    • Size is <% = intI %> </font><br/>

    • <% Next %> <!-note->

    • <!-what will you see from this?->

    • <!-fontcolor.aspx 'notes->


    Using asp net with forms

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


    Form2 html

    form2.html

    <html><body>

    • <form method="get"

    • action="resp2.aspx">

      Last Name <input type="text"

      name="custName" id="custName">

      </body></html>

      <!--need to refresh?-->


    Default aspx

    Default.aspx

    • <%@ Page Language="VB" %>

    • <html><body>

    • Input from form:

    • <%

    • Dim strCustName as String

      strCustName = _

      Request.QueryString("custName")

    • Response.Write("last name is " & _

      strCustName)

    • %></body></html>


    Using asp net with forms 2

    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


    Using visual studio net for asp

    Using Visual Studio.NET for ASP

    • using Visual Studio.NET or Visual Web Developer Express 2008

      • 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

      • double click the screen (outside of the label) to start a Page_Load Sub

      • paste code on following page into Sub


    Vb net web code

    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


    Run code

    Run Code

    • click Start

    • (first time) modify the web.config…>OK

    • view code and then make changes as necessary


    Asp net code samples

    ASP.NET Code Samples

    • CIS 451 ASP Code Samples

    • W3 Schools online tutorials and demonstration code


  • Login