ASP Components (ii)

Source: Internet
Author: User
Tags command line file size file upload html tags iis mail zip microsoft iis
In the last lecture, we learned how to create components, use browser capabilities components, File Access Components, AD rotator components, and content linking components, and also know the CreateObject method of the server object, MapPath method and HTMLEncode method. This lecture will continue with component learning.

One, email component: NTS collaboration Data Objects
We often see on the internet, many sites provide the online letter function (that is, the form to implement question submit, support or feedback, etc.) or to send a confirmation message to visitors. This feature is difficult to achieve for the personal homepage because of the need for additional support from the home page provider (the online writing on my personal homepage is written in CGI, not with ASP), here is a simple example of its rationale:
Special Note: All of the examples in this lecture are debugged on Windows NT4.0 Server+iis (Internet information Server) 4.0, but most of them also apply to WINDOWS9.X+PWS. But to learn to use ASP, it is best to install a Windows NT and windows95/98 coexist (not installed not to be afraid, very easy, as long as the machine a little better on the line, NT installation can automatically make a win-nt/win9.x double boot).
<% ' wuf30.asp
Dim Mail
' Create an email component
Set Mail = Server.CreateObject ("CDONTS. NewMail ")
' Send email
Mail.send "From@intldept.com", "To@intldept.com", "Subject", "body"
Set Mail = Nothing
%>
This is one of the simplest examples, in fact, using this component, you can send plain text-formatted mail or HTML hypertext format mail, which also supports CC and Bcc (BCC), and can contain pictures and attachments, and even receive mail, which should be said to be more powerful. But I don't personally appreciate it, because to use this component, you must install the Windows NT Server and IIS4.0 SMTP service (Microsoft Style), and the component does not support the POP3 protocol. Therefore, if you do not normally send mail using this component, you can open Internet Server Manager to see if the default SMTP site is started (start) and some related settings. However, if you are a Microsoft fan, you can go to my homepage (http://wuf.bentium.net/) To download the components of the routines wuf31.asp and sendmail.asp yourself to study.

Ii. use of third party components
So far, the components we've described are contained in IIS4.0, and you can use them directly. In addition, you can obtain the following two components from the Microsoft IIS Resource Kit CD (or go to Http://www.microsoft.com/iis to see if there is a download):
L Page Counter component: Web counter
L Permission Checker component: Web Access permission Confirmation component
The introduction of the IIS4.0 built-in components is here to stay, but the learning of ASP components continues, on the one hand because the IIS4.0 built-in components are few, on the other hand, these components may not be powerful enough to suit your needs. Therefore, a larger amount of resources is the online existing hundreds of third-party components, some of them are free, some provide a functional limit version or evaluation version, of course, more money (a component to three-digit $, there is no mistake!) is simply a roundabout "blackmail", the use of these components, enough to make you a fake ASP master, so that you can quickly and easily make a powerful homepage, no longer have "Ching" sigh. Let's look at this feeling through a few examples.

(i) File Upload component Aspsmartupload (free)
Download this component first: Http://www.aspsmart.com/liblocal/download/EN/aspSmartUpload.zip, the file size is about 100K (also can go to my site to download). After the download of the package, there are more than 30 files, located in different directories, you can refer to the documentation of their own research, here just a complete example to illustrate how to use third-party components.
Locate the two files for AspSmartUpload.dll and AspSmartUploadUtil.dll, and at the command prompt of the Web server, use the "Regsvr32.exe aspsmartupload.dll" and " regsvr32.exe aspsmartuploadutil.dll the command line to register the component (if you are using Regsvr32.exe for the first time, you can first copy the two DLL files to the Web server's "Winnt/system32" or " Windows/system "Directory", if the registration is successful, the pop-up window will have "succeeded" (note: the use of Third-party components must be registered before, and some Third-party components installed by the way, can automatically register, and more like this, the need to manually register themselves). After the registration is successful, the next step is to write the code using the component, which consists of two files (note that you do not use the Chinese filename when testing):
wuf32.htm– the front-end Web page that uploads files (form)
<HTML>
<style type= "Text/css" >
<!--
Input {font-family: "Song Body", "Times New Roman"; font-size:9pt line-height:16pt}
-->
</style>

<body bgcolor= "White" >
Upload the file of the Web page (can upload the number of files you define, but the file name can not contain Chinese)
<HR>
<form method= "POST" action= "wuf34.asp" enctype= "Multipart/form-data" >
<!--TEXT-->
User name: <input type= "TEXT" name= "MyText" value= "" ><br>

<!--PASSWORD-->
Password: <input type= "PASSWORD" name= "MyPassword" "value=" "><br>

<!--HIDDEN-->
<input type= "hidden" name= "Myhidden" value= "hidden" ><br>

<!--file-->
File 1:<input type= "file" Name= "FILE1" size= "M" ><BR>
File 2:<input type= "file" Name= "FILE2" size= "M" ><BR>
File 3:<input type= "file" Name= "FILE3" size= "M" ><BR>
File 4:<input type= "file" Name= "FILE4" size= "M" ><BR>
<input type= "SUBMIT" value= "Upload" >
</FORM>
</BODY></HTML>
Press the "Upload" button and the background is handled by the file wuf34.asp (you can also download a simpler wuf33.asp):
File Upload results:
<HR>
<%
Dim mysmartupload, item, value, file
' first create the component as follows
Set mysmartupload = Server.CreateObject ("Aspsmartupload.smartupload")

Mysmartupload.upload

' To get the value of each item in the from form with a For Each loop
For each item in Mysmartupload.form
For each value in Mysmartupload.form (item)
Response.Write (Item & "=" & Value & "<BR>")
Next
Next

Response.Write "<Hr>"
' Uploading file data
' Response.Write ("number of files =" & MySmartUpload.Files.Count & "<BR>")
Response.Write ("Total bytes =" & mySmartUpload.Files.TotalBytes & "Bytes<br><br>")
Response.Write ("File list:" & "<Br>")

' For every file--there's a simpler way to see wuf33.asp
For each file in Mysmartupload.files
If not file. IsMissing Then
' With the original filename stored under C:\temp
File. SaveAs ("c:\temp\" & file. FileName)
Response.Write (file. FileName & "(" & file. Size & "bytes) <BR>")
End If
Next
Set mysmartupload = Nothing
%>
</BODY>
</HTML>
For more on this component, more detailed usage, features (such as restricting the type of uploaded files, size, uploading to the database, downloading files or database fields, and so on), you can see the sample or research foreign language help yourself. If you feel too tired to read E, you can also download a national-produced file upload components, which have Chinese help and examples, or good, download the address: Http://www.chinaasp.com/program/fileup.zip.

(ii) Graphic components: Dundas Pie Chart (pie chart)
First listen to what the component provider says: "Flash performance, high quality graphics, powerful, high speed, incomparable flexibility", wow, bragging trumps trinket, is that so, to see one of the results:
With such a pie chart, you can also like the Sina network to do the investigation, blowing such a good thing is free, you still wait for what, quickly drive your slow cat to pull down:
(1) 3dpiecsc.exe:http://www.dundas.com/downloads/freeproducts/files/3dpiecsc.exe
(2) Fpdocinst.exe:http://www.dundas.com/downloads/freeproducts/files/fpdocinst.exe
3DPieCSC.EXE includes this component, which is the documentation, the installation file, and I installed it in the server's "C:\Inetpub\3dPieCSC" directory, which brings up two of complex sample programs to showcase its stunning performance and is harder to figure out. Here's a simple and practical example of popularity:
wuf36.htm, invoke ASP file via tag:
<HTML><BODY>

</BODY></HTML>
Wuf37.asp, used to generate graphics (in the same vein as above, do not use Chinese in your code):
<%@ Language=vbscript%>
<% Option Explicit
Dim Objpiechart
Set Objpiechart = Server.CreateObject ("Dundas.piechartserver.1") ' Create component first

' Set working directory
Objpiechart.diroutput = "C:\Inetpub\3dPieCSC\Sample\Chart\"
' Set the directory where the template file resides
Objpiechart.dirtemplate = "C:\Inetpub\3dPieCSC\Sample\Templates\"
' Material catalogue-you can easily change the texture and color of the graphic
Objpiechart.dirtexture = "C:\Inetpub\3dPieCSC\Sample\Textures\"

' Select a template file that can be edited or modified by itself
Objpiechart.loadtemplate "PIEINTHESKY.CUC"
' Graphic title
Objpiechart.title = "This is a Sample"

' Add each item, including weight label description
Objpiechart.adddata, "item1:40%", "the"
Objpiechart.adddata, "item2:30%", "USA"
Objpiechart.adddata, "item3:30%", "other"

' Output is a graphic, can specify width and height
Objpiechart.sendjpeg 400,300

Set Objpiechart = Nothing
%>
To be honest, this free thing is good, the routines it offers are too complicated to be able to touch. Now you may want to come up with a extrapolate, mastery, how to get a histogram, and indeed there is such a component: Shotgraph, but there is no need to make such a complex, you only need to prepare a columnar picture (not to do!). See other people on the Web page, save another to do it, using HTML tags weight, height proportional stretching and compression on the line ( height = 10>).

In addition, in order to make up for this lecture at the beginning of a responsible brief, here solemnly recommend two email components:
(1) Aspsmartmail:http://www.aspsmart.com/liblocal/download/en/aspsmartmail.zip, please do not use Chinese in the code, otherwise you can not send out a letter, see routine wuf35.asp.
(2) W3 Jmail:http://download.dimac.net/jmail/jmail.exe.
(3) chinamail:http://wuf.bentium.net/, I write all Chinese email components.

For the components of the feelings, I personally is very complex and heavy, IIS4.0 built-in components are really too little, but the e-text components on the Internet many do not support Chinese, use it is not cool, then why not use domestic components, you go to the best http://www.chinaasp.com/ I know, the listed components are few, chilling, then only one way, that is their own writing (but the average person can write themselves?) This is a question). I agree with Chinaasp's appeal, presumably means that there is no software company in the country to publish ASP components, in the ASP, although the book is tons, but the taste is not high. Indeed, when I was invited to write this lecture, on the market on the ASP book is still very few, but now, suddenly come out a lot, I still suggest you buy foreign books, one has CD-ROM, and indeed import generally speak better, read like so, also not rigid.

Finally to provide you with a number of component resources site:
(1) http://www.serverobjects.com/
(2) http://www.15seconds.com/
(3) http://www.activeserverpages.com/
(4) http://www.softartisans.com/


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.