همه ي فرم هاي اي اس پي
<% Response.Expires=0 %>
<
HTML>
<
HEAD></HEAD>
<
BODY BGColor=White Text=Black>
<STYLE>
.btn {Width:100%}
</STYLE>
<%
Dim Page ' Local var For page #
Dim cn ' Connection object
Dim rs ' Recordset object
Dim Action ' Button pressed
Dim PageSize ' How far To page
Dim UpdSQL, MySQL ' String To hold SQL
Dim i ' Loop counter
Dim item, value ' Used To retrieve changed fields
Dim issueUpdate ' After Save button press, any changes to make?
Action = Request.Form("NavAction")
if Request.Form("Page") <> "" Then
Page = Request.Form("Page")
Else
Page = 1
End if
if Request.Form("PageSize") <> "" Then
PageSize = Request.Form("PageSize")
Else
PageSize = 5
End if
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open Application("guestDSN")

' Get initial recordset
Set rs = Server.CreateObject("ADODB.Recordset")
MySQL = "SELECT * FROM AUTHORS"
rs.PageSize = PageSize
rs.Open MySQL, cn, adOpenKeyset, adLockOptimistic
Select Case Action
Case "Begin"
Page = 1
Case "Back"
if (Page > 1) Then
Page = Page - 1
Else
Page = 1
End if
rs.AbsolutePage = Page
Case "Forward"
if (CInt(Page) < rs.PageCount) Then
Page = Page + 1
Else
Page = rs.PageCount
End if
rs.AbsolutePage = Page
Case "End"
rs.AbsolutePage = rs.PageCount
Case "Save"
' Grab the proper record, Then update
' This routine is hard coded For AU_ID As the key field.
' To alter this to work With another DB Table you will need to
' Use the proper primary key instead of AU_ID.
rs.Close
MySQL = "SELECT * FROM AUTHORS WHERE au_id = '" & Request.Form("Au_id") & "'"
rs.MaxRecords = 1
rs.Open MySQL, cn, adOpenStatic, adLockOptimistic
UpdSQL = "UPDATE AUTHORS "
issueUpdate = False
For i = 0 To (rs.Fields.Count - 1)
item = rs.Fields(i).Name
value = Request.Form(item)
' Only update items that have changed
if (rs(i) <> value) Then
if issueUpdate = False Then
UpdSQL = UpdSQL & "SET "
Else
UpdSQL = UpdSQL & ","
End if
issueUpdate = True
Select Case VarType(rs.Fields(i))
' Determine datatype For proper SQL UPDATE syntax
' NOTE: Not all data types covered
Case vbString, vbDate
UpdSQL = UpdSQL & item & "='" & value & "'"
Case vbNull
Case vbInteger
UpdSQL = UpdSQL & item & "=" & value
Case vbBoolean
if value Then
UpdSQL = UpdSQL & item & "= 1"
Else
UpdSQL = UpdSQL & item & "= 0"
End if
End Select
End if
Next
UpdSQL = UpdSQL & " WHERE au_id = '" & Request.Form("Au_id") & "'"
if issueUpdate Then
cn.Execute UpdSQL
Set rs = cn.Execute(MySQL)
End if
Case "New"
' response.write "New"
rs.AddNew
Case "Bookmark"
Session("myBookMark") = rs.BookMark
Case "Goto"
if Not IsNull(Session("myBookMark")) Then
rs.BookMark = Session("myBookMark")
End if
Case Else
rs.MoveFirst
End Select
%>
<
CENTER>
<!-- 2 Column Table -->
<!-- 1 Column For Data, 1 for Controls -->
<
TABLE Align=Center border=1 BGColor=Navy
BorderColorDark=Navy BorderColorLight=Aqua BorderColor=Blue>
<!-- Table Header -->
<
TH Colspan=2>
<
FONT Color=White Size=+2><CENTER>Navigating Example</CENTER></FONT>
</
TH>
<!-- Main Table Content -->
<
TR><TD>
<!-- Nested Table 1 -->
<!-- Author Detail -->
<
FORM Action=all_form.asp Method="POST">
<
TABLE Align=Left BORDER=0 BGColor=Gray Text=White>
<%
For i = 0 To rs.Fields.Count - 1
%>
<
TR><TD><B><%= rs.Fields(i).Name %></B></TD>
<
TD><INPUT Type=text Name="<%= rs.Fields(i).Name %>" Value="<%= rs(i) %>"></TD>
</
TR>
<%
Next
%>
</
TABLE>
</
TD>
<
TD BGColor=Black Width=100>
<!-- Nested Form 2 -->
<!-- Persisted Values -->
<
INPUT Type="Hidden" Name="PageSize" Value="1">
<
INPUT Type="Hidden" Name="Page" Value="<%= Page %>">
<!-- Navigation Buttons -->
<
INPUT TYPE="Submit" Name="NavAction" Value="Begin" Class=Btn><BR>
<
INPUT TYPE="Submit" Name="NavAction" Value="Back" Class=Btn><BR>
<
INPUT TYPE="Submit" Name="NavAction" Value="Forward" Class=Btn><BR>
<
INPUT TYPE="Submit" Name="NavAction" Value="End" Class=Btn><P>
<
INPUT TYPE="Submit" Name="NavAction" Value="Save" Class=Btn><BR>
<
INPUT TYPE="Submit" Name="NavAction" Value="New" Class=Btn><P>
<
INPUT TYPE="Submit" Name="NavAction" Value="Bookmark" Class=Btn><BR>
<
INPUT TYPE="Submit" Name="NavAction" Value="Goto" Class=Btn><P>
</
TD>
</
TR>
</
TABLE>
</
FORM>
<
P>
<!-- Floating Frame -->
<
IFRAME width=70% height=180 src="list.asp?auid=<%= rs( </Include/code.asp?source=/ado/samples/list.asp?auid=<%= rs(>"au_id") %>" FrameBorder=1 Scrolling=No>
<
FRAME width=70% height=180 src="list.asp?auid=<%= rs( </Include/code.asp?source=/ado/samples/list.asp?auid=<%= rs(>"au_id") %>">
</
IFRAME>
</
CENTER>
</
BODY>
</
HTML>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ادامه

Aspبه استاتیک htmlبرای بالا بردن سرعت
Dim fs, fsmyfile, todayfile, ckdayfile, cr, qt
'Get name of file as it needs to be toda

' y
todayfile="Cur"&cstr(month(date()))&cstr(day(date( )))
ckdayfile=""&cstr(month(date()))&cstr(day(date())) &""
todayfile=trim(todayfile)&".asp"
'Create FileSystemObject
Set fs = CreateObject("Scripting.FileSystemObject")

'File may not be built
On Error Resume Next

'Check to see if we already have the HTM

' L file Built
Set fsmyfile = fs.OpenTextFile("c:\inetpub\scripts\asp\jeff\"+tod ayfile,1,0)
if err<>0 Then 'Need To build today
fsmyfile.Close 'Close File
Set fsmyfile = fs.OpenTextFile("c:\inetpub\scripts\asp\jeff\"+tod ayfile,8,1,0)
cr=chr(13) 'Save some typing (I'm lazy)
qt=chr(34) 'The Only way I could Get the quote marks correct
codeout="<%@ LANGUAGE=""VBSCRIPT"" %"&">"&cr
codeout=codeout&"<%"&cr
codeout=codeout&"today="&qt&cstr(month(date()))&cs tr(day(date()))&qt&cr
codeout=codeout&cr&"if today<>"&qt&ckdayfile&qt&" then"&cr
codeout=codeout&"response.redirect("&qt&"wrtest.as p"&qt&")"&cr
codeout=codeout&"else %"&">"&cr
fsmyfile.Writeline(""&codeout&cr&_
"<HTML>"&cr&_
"<TITLE>Write and Check Raw HTML For Speed</TITLE>"&cr&_
"<BODY>"&cr&_
"Hello todays file is called "&todayfile&cr&_
"</BODY>"&cr&_
"</HTML>"&cr&_
"<"&"%End if"&cr&_
"%"&">")
fsmyfile.close
fs.close
Response.Redirect(todayfile) 'Send them to new file
else
fsmyfile.close
fs.Close
Response.Redirect(todayfile) 'Send them to current file
End if%>

__________________



دیدن فايل
'Place this in a module for use in the f

' uture:
Public Sub Object_Center(Frm As Form, Cntrl As Object)
'To call it, you would simply do:
'Call Object_Center(Form1, Text1)
'and that will center Text1 in the middl

' e of your
'screen, no matter how big, or where For

' m1 is
Cntrl.Top = (Screen.Height * 1#) / 2 - Cntrl.Height / 2
Cntrl.Left = (Screen.Width * 1#) / 2 - Cntrl.Width / 2
End Sub<%@ LANGUAGE=JSCRIPT %>
<%Response.Buffer = true;%>
<%
Response.AddHeader( "content-type",
"text/html; charset=UTF-8" );
Response.AddHeader( "cache-control",
"no-cache" );
Response.Expires = 0;
var fileName = new String( ""+Request( "file" ) );
var line = new Number( ""+Request( "line" ) );
var fso = Server.CreateObject( "Scripting.FileSystemObject" );
var iFile = fso.OpenTextFile(
Server.MapPath( fileName ), 1, false, 0 );
var i = 1;
%>
<HTML>
<HEAD>
<TITLE>File View page</TITLE>
<style>
body, td { font: 8pt Courier; }
.blackbg { font-weight: bold; background: #000000; color:#FFFFFF; }
</style>
</HEAD>
<BODY>
<TABLE cellpadding="3" cellspacing="0">
<%
while( !iFile.AtEndOfStream )
{
Response.Write( "
<TR" );
if( i == line )
{
Response.Write(" bgcolor=\"#FFCCCC\"");
}
Else
if( i & 1 )
{
Response.Write(" bgcolor=\"#FFFFEE\"");
}
Response.Write("
><TD align=\"right\"><B>");
Response.Write(i+"
</B></TD><TD nowrap>");
Response.Write(Server.HTMLEncode(
iFile.ReadLine() )+"
</TD></TR>\r\n" );
i++;
}
iFile.Close();
%>
</TABLE>
</BODY>
</HTML>







پسورد اي اس پي

password.asp
<%@ LANGUAGE="VBSCRIPT" %>
<!--- This example is a simple login system --->
<HTML>
<HEAD>
<TITLE>Password.asp</TITLE>
</HEAD>
<BODY>
<FORM ACTION="engine.asp" NAME="form1" METHOD="post">
User Name:
<INPUT TYPE="text" SIZE=30 NAME="username">
<P>
Password:
<INPUT TYPE="password" SIZE=30 NAME="password">
<P>
<INPUT TYPE="submit" VALUE="Login">
</FORM>
</BODY>
</HTML>
--------------------------------------------------------------------------------
engine.asp
-------------
<%@ LANGUAGE="VBSCRIPT" %>
<%
' Connects and opens the text file
' DATA FORMAT IN TEXT FILE= "username<

' ;SPACE>password"
Set MyFileObject=Server.CreateObject("Scripting.FileSy stemObject")
Set MyTextFile=MyFileObject.OpenTextFile(Server.MapPat h("\path\path\path\path") & "\passwords.txt")
' Scan the text file to determine if the

' user is legal
While Not MyTextFile.AtEndOfStream
' If username and password found
if MyTextFile.ReadLine = Request.form("username") & " " & Request.form("password") Then
' Close the text file
MyTextFile.Close
' Go to login success page
Session("GoBack")=Request.ServerVariables("SCRIPT_ NAME")
Response.Redirect "inyougo.asp"
Response.end
End if
WEND
' Close the text file
MyTextFile.Close
' Go to error page if login unsuccessful

'
Session("GoBack")=Request.ServerVariables("SCRIPT_ NAME")
Response.Redirect "invalid.asp"
Response.end
%>
------------
invalid.asp
-----
<%@ LANGUAGE="VBSCRIPT" %>
<!--- This example is a simple login system --->
<HTML>
<HEAD>
<TITLE>invalid.asp</TITLE>
</HEAD>
<BODY>
You have entered an invalid username or password.
<P>
<A HREF="password.asp">Try To log In again</A>
</BODY>
</HTML>
------
inyougo.asp
------
<%@ LANGUAGE="VBSCRIPT" %>
<!--- This example is a simple login system --->
<HTML>
<HEAD>
<TITLE>In You Go</TITLE>
</HEAD>
<BODY>
You have now entered the password protected page.
</BODY>
</HTML>
-------
passwords.txt
----
gates bill
burns joe




جستجوي فايل هاي اي اس پي


<%@LANGUAGE="VBSCRIPT"%>
<%
Response.AddHeader "Pragma", "No-Cache" 'try Not To cache page
Response.CacheControl = "Private" 'try Not To cache page
server.scripttimeout = 300 'script will time out after 5 minutes
%>
<HTML>
<HEAD><TITLE>Find Files Using ASP</TITLE>
<style>
body {font:10pt Arial;background-color:papayawhip;color:antiquewhite;font-weight:bold;margin-top:0px;margin-left:0px;margin-right:0px}
A:link {color:black;text-decoration:none}
A:hover {color:red;text-decoration:underline}
A:visited {color:black;text-decoration:none}
td {color:black;border-bottom:1pt solid black;font:9pt Arial}
th {color:black;border-bottom:1pt solid black;font:9pt Arial;font-weight:bold}
</style>
</HEAD>
<BODY>
<DIV style="background-color:tan">
<CENTER>
Find Files<BR>
<%
Dim filecounter, searchtext, directory 'dimention variables
Dim fcount, fsize
filecounter = 0 'initialize filecounter To zero
searchtext = Trim(request("SearchText")) 'get the querystring SearchText
directory = Trim(request("Directory")) 'get the querystring Directory
if directory = "" Then directory = "c:\" 'if no directory the Set to c:\
'Write the Search Form To the page
response.write "<FORM action='FindFiles.asp' method=get>Search For:" & _
" <INPUT type=text name=SearchText size=20 value=" & Chr(34) & searchtext & _
Chr(34) & "> Change Directory: <INPUT type=text name=Directory size=20 value=" & _
Chr(34) & directory & Chr(34) & "> <INPUT style='background-color:blanchedalmond;" & _
"color:chocolate' type=submit value='Start Search'></FORM><BR></DIV>"
if searchtext <> "" Then 'if there is a file To search For then search
response.write "<TABLE border=0 width='100%'>"
response.write "<TR><TH width='60%'>File Name</TH><TH width='10%'>File Size</TH><TH width='30%'>Date Modified</TH></TR>"
'create the recordset object To store
'the filepath, filename, filesize and last modified Date
Set rs = createobject("adodb.recordset")
rs.fields.append "FilePath",200,255
rs.fields.append "FileName",200,255
rs.fields.append "FileSize",200,255
rs.fields.append "FileDate",7,255
rs.open
Recurse directory 'call the subroutine to traverse the directories
Sub Recurse(Path)
'create the file system object
Dim fso, Root, Files, Folders, File, i, FoldersArray(1000)
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set Root = fso.getfolder(Path)
Set Files = Root.Files
Set Folders = Root.SubFolders
fcount = 0 'zero out the file count variable
'traverse through the subdirectories In the current directory
For Each Folder In Folders
FoldersArray(i) = Folder.Path
i = i + 1
Next
'traverse through the files In the current folder or subfolder
For Each File In Files
'check if the search String is found
num = InStr(UCase(File.Name), UCase(searchtext))
'if it is Then update the recordset and sort it
if num <> 0 Then
filecounter = filecounter + 1
rs.addnew
rs.fields("FilePath") = File.Path
rs.fields("FileName") = File.Name
rs.fields("FileSize") = File.Size
rs.fields("FileDate") = File.DateLastModified
rs.update
rs.Sort = "FileName ASC"
End if
Next
'recurse through the current directory until
'all subfolders have been traversed
For i = 0 To UBound(FoldersArray)
if FoldersArray(i) <> "" Then
Recurse FoldersArray(i)
Else
Exit For
End if
Next
End Sub
'if files were found Then write them To the document
if filecounter <> 0 Then
filecounter = 0
Do While Not rs.eof
filecounter = filecounter + 1
response.write "<TR><TD width='50%' valign=top><A href=""" & rs.fields("FilePath") & """>" & rs.fields("FileName") & "</TD><TD width='10%' align=right valign=top>"
'get the file size so we can
'assign the proper Bytes, KB or MB value
fsize = CLng(rs.fields("FileSize"))
'if less than 1 kilobyte Then it's Bytes
if fsize >= 0 And fsize <= 999 Then
fnumber = FormatNumber(fsize,0) & " Bytes"
End if
'if 1 KB but less Then 1 MB then assign KB
if fsize >= 1000 And fsize <= 999999 Then
fnumber = FormatNumber((fsize / 1000),2) & " KB"
End if
'if 1 MB or more Then assign MB
if fsize >= 1000000 Then
fnumber = FormatNumber((fsize / 1000000),2) & " MB"
End if
'write Each file and corresponding info To the document
response.write fnumber & "</TD><TD width='30%' align='center'>" & rs.fields("FileDate") & "</TD></TR>"
rs.movenext
Loop
response.write "</TABLE>" 'end the table
Else
'no files were found
End if
End if
%>
</BODY>
</HTML>






با تشكر