Skills
1. Several common functions
Round (pi, 2) rounded
FormatNumber (k,4) ' formats K as a number with four-bit decimal points.
eg. If K =20000 is shown as 20,000.00 if FormatNumber (k,0) is 20,000
Replace (Expression,find,replacewith) ' returns a string in which the specified substring has been replaced by another substring
Left (string,length) ' Returns a specified number of strings from the left-hand side of the string.
Split (expression[, delimiter[, count[, start]]] ' Returns a one-dimensional array based on 0 that contains the specified number of substrings.
eg. This split (String,[delimiter]) is used to divide strings using delimiter (characters used to identify substring bounds)
Instr (string1,string2) ' Returns the position of the first occurrence of a string in another string
Eg1. If InStr (addation, "Password Configuration table") <>0 Then ' description exists
EG2. If InStr (str, "AP") >0 a bad distinction between str = (AP,AP&AC), just change (' ap ', ' Ap&ac '), and then use InStr (STR, ' AP ')
2. pop-up window pick value
function PICKUPSP (Spdisid,pjnum,pdcode)
{
Window.opener.<%=theform%>. refnum<%=spid%>.value=spdisid;
Window.opener.<%=theform%>. lines<%=spid%>.value=pjnum;
window.opener.<%=theform%>.kokey<%=spid%>.value=pdcode;
Window.close ();
}
3. asp control picture display size (equal scaling)
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language= "JavaScript" >
<!--
var Flag=false;
function DrawImage (IMGD) {
var image=new image ();
IMAGE.SRC=IMGD.SRC;
if (image.width>0 && image.height>0) {
Flag=true;
if (image.width/image.height>= 164/112) {
if (image.width>164) {
imgd.width=164;
imgd.height= (image.height*164)/image.width;
}else{
Imgd.width=image.width;
Imgd.height=image.height;
}
imgd.alt=image.width+ "X" +image.height;
}
else{
if (image.height>112) {
imgd.height=112;
Imgd.width= (image.width*112)/image.height;
}else{
Imgd.width=image.width;
Imgd.height=image.height;
}
imgd.alt=image.width+ "X" +image.height;
}
}
}
-->
</script>
</HEAD>
<BODY>
<a href= "http://www.163design.net/a/q/img.jpg" target= "_blank" ></a>
</BODY>
</HTML>
4. Operations on database tables (insert/update/delete) in ASP, using transaction processing and support for multiple transaction processing.
In the ASP's database object linked object, the properties are provided:
BeginTrans Transaction Start
CommitTrans Transaction Submission
RollbackTrans transaction Rollback
<%
On Error Resume Next ' error occurs after processing
' Using Transactions in ASP '
Set conn=server.createobject ("ADODB. Connection ")
Conn. Open "Course_dsn", "Course_user", "Course_password"
Conn.begintrans ' Start a transaction
Sql= "Delete from User_info"
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open sql,conn,3,3
If Conn.errors.count>0 then ' has an error occurred
Conn.rollbacktrans ' Roll back
Set rs=nothing
Conn.close
Set conn=nothing
Response.Write "Transaction failure, roll back to the state before the change!" "
Response.End
Else
Conn.committrans ' commits the transaction
Set rs=nothing
Conn.close
Set conn=nothing
Response.Write "Trading Success! "
Response.End
End If
%>
In the ASP, do not provide the end of the transaction, BeginTrans only for their own domain, similar to the variable declaration, if in the function body BeginTrans, then the object is used only for this function body, if BeginTrans in the function body, in the page level, The scope of the transaction begins at BeginTrans, and the end of the page is in the managed state of the transaction.
[1] [2] Next page