1 / 14

.NET Library Objects

.NET Library Objects. So far we have looked at the following objects in learning about ASP.NET: Controls Used to control the screen / interface and gather input and display output. Variables Used to control the computers RAM and allow it to store data / perform calculations. Custom Objects

channer
Télécharger la présentation

.NET Library Objects

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. .NET Library Objects So far we have looked at the following objects in learning about ASP.NET: • Controls • Used to control the screen / interface and gather input and display output. • Variables • Used to control the computers RAM and allow it to store data / perform calculations. • Custom Objects • Used by programmers to perform specialised tasks.

  2. System Input-Output Provides tools for file input and output Drawing Provides graphical drawing tools Web Provides tools for Internet interconnectivity Data Provides tools for accessing databases The .NET Library • The .NET part of ASP.NET refers to a library of objects that allow you the programmer to perform a huge range of tasks

  3. We will look at two examples • The mail message object • Used to create and send emails. • The SMTP client object • Used to control a mail server.

  4. The Mail Message Object • It may be found in the following part of the .NET framework… System.Net.Mail • To create a mail message object we would use the following line of code… • Dim myMessage As New System.Net.Mail.MailMessage(From, to, subject,body)

  5. So let’s say we wanted to create the following email…

  6. We would use the following line of code… • Dim myMessage As New System.Net.Mail.MailMessage (“you@whatever.com”, “johnsmith@nowhere.com”, “Hello John”, ”Hi this is a test!”)

  7. The SMTP Client Object • A mail server is a specialised computer that deals with the sending and receiving of email messages • DMU mail.cse.dmu.ac.uk • Virgin smtp.ntlworld.co.uk • Orange smtp.wannadoo.co.uk • Tiscali smtp.tiscali.co.uk

  8. SMTP • SMTP (Simple Mail Transfer Protocol) is the name of the software that send emails. • It runs on a named machine so we need to know the name of the machine in order to send emails. • The SMTP client is stored in : System.Net.Mail • So to create a new SMTP client object we would use the following code... • Dim Server As New System.Net.Mail.SmtpClient("name of server") • E.g. • Dim Server As New System.Net.Mail.SmtpClient("mail.cse.dmu.ac.uk")

  9. Sending the Mail Message Dim myMessage As New System.Net.Mail.MailMessage (“you@whatever.com”, “johnsmith@nowhere.com”, “Hello John”, ”Hi this is a test!”) Dim Server As New System.Net.Mail.SmtpClient("mail.cse.dmu.ac.uk") Server.Send(myMessage)

  10. Working Example • To see all of this working we shall look at the code for the resend password page “resend.aspx”

  11. What is an Object Again? “An object is a way of representing computer technology in such a way so that we may send it instructions and data.” Creating an email and controlling a mail server are quite complex tasks, however “wrapping up” the complexity in objects means that we can perform this whole process in three lines of code.

  12. Questions 1. Correct the following code...

  13. Questions 2. Write down as many uses you can think of on the web for an email object 3. The following is the declaration for another .NET library object: Dim MyFile As New System.IO.StreamReader("myfile.txt") This object is used to read data from a file stored on the hard disk, in this case “myfile.txt”

  14. Questions Think about what methods and properties this object might use to manipulate the file so that we can read the data. Write a list of possible methods and properties. Where might we find information on the methods and properties for this type of object?

More Related