Hello World!
HTML
HTML Basic
HOME LINK
Species
Click on a species to see what type it is:
- Owl
- Salmon
- Tarantula
Click on a species to see what type it is:
Click on a species to see what type it is:
https://ngonnguxahoi.blogspot.com/2021/10/blog-pages.html?m=1
https://ngonnguxahoi.blogspot.com/2021/10/blogs-category.html?m=1
| <%Response.Write(x.value)%> | <%next rs.MoveNext%>
| " & x.name & " | ") next%>
|---|
| <%Response.Write(x.value)%> | <%next rs.MoveNext%>
| " & x.name & " | ") next%>
|---|
| <%Response.Write(x.value)%> | <%next rs.MoveNext%>
| " & x.name & " | ") next%>
|---|
| <%Response.Write(x.value)%> | <%next rs.MoveNext%>
| " & x.name & " | ") next%>
|---|
| <%Response.Write(x.value)%> | <%next rs.MoveNext%>
| " & x.name & " | ") next%>
|---|
| <%Response.Write(x.value)%> | <%next rs.MoveNext%>
| Companyname | Contactname | Country |
|---|---|---|
| " & rs.fields("companyname") & " | ") response.write("" & rs.fields("contactname") & " | ") response.write("" & rs.fields("country") & " | ") response.write("
| " & x.name & " | ") next%>
|---|
| <%Response.Write(x.value)%> | <%next rs.MoveNext%>
| " & x.name & " | ") next%>
|---|
| <%Response.Write(x.value)%> | <%next rs.MoveNext%>
This example returns the value of the first column in the first two records:
") response.write(p(0,0)) response.write("This example returns the value of the first three columns in the first record:
") response.write(p(0,0)) response.write("| <%Response.Write(str)%> |
The example uses the Content Linking Component to navigate between the pages in a text file.
The example below builds a table of contents.
<% dim c dim i set nl=server.createobject("MSWC.Nextlink") c = nl.GetListCount("text\links.txt") i = 1 %>The text file contains a list of page urls and link descriptions. It contains one line of text for each page. Note that the url and description MUST be separated by the TAB character.
<% set cr=server.createobject("MSWC.ContentRotator") response.write(cr.ChooseContent("text/textads.txt")) %>NOTE: Because the content strings are changed randomly in the text file, and this page has only four content strings to choose from, sometimes the page will display the same content strings twice in a row.
<% Set MyBrow=Server.CreateObject("MSWC.BrowserType") %>| Client OS | <%=MyBrow.platform%> |
| Web Browser | <%=MyBrow.browser%> |
| Browser version | <%=MyBrow.version%> |
| Frame support? | <%=MyBrow.frames%> |
| Table support? | <%=MyBrow.tables%> |
| Sound support? | <%=MyBrow.backgroundsounds%> |
| Cookies support? | <%=MyBrow.cookies%> |
| VBScript support? | <%=MyBrow.vbscript%> |
| JavaScript support? | <%=MyBrow.javascript%> |
NOTE: Because images are changed randomly, and because this page has few images to choose from, it will often display the same advertisement twice in a row.
NOTE: The AdRotator does not work with Internet Information Server 7 (IIS7).
<% Set fs=Server.CreateObject("Scripting.FileSystemObject") If (fs.FileExists("c:\winnt\cursors\3dgarro.cur"))=true Then Response.Write("File c:\winnt\cursors\3dgarro.cur exists.") Else Response.Write("File c:\winnt\cursors\3dgarro.cur does not exist.") End If set fs=nothing %> <% Set fs=Server.CreateObject("Scripting.FileSystemObject") If fs.FolderExists("c:\temp") = true Then Response.Write("Folder c:\temp exists.") Else Response.Write("Folder c:\temp does not exist.") End If set fs=nothing %> <% Set fs=Server.CreateObject("Scripting.FileSystemObject") if fs.driveexists("c:") = true then Response.Write("Drive c: exists.") Else Response.Write("Drive c: does not exist.") End If Response.write("This is the text in the text file:
<% Set fs=Server.CreateObject("Scripting.FileSystemObject") Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1) Response.Write(f.ReadAll) f.Close Set f=Nothing Set fs=Nothing %>This is the first five characters from the text file:
<% Set fs=Server.CreateObject("Scripting.FileSystemObject") Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1) Response.Write(f.Read(5)) f.Close Set f=Nothing Set fs=Nothing %>This is the first line of the text file:
<% Set fs=Server.CreateObject("Scripting.FileSystemObject") Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1) Response.Write(f.ReadLine) f.Close Set f=Nothing Set fs=Nothing %>This is all the lines in the text file:
<% Set fs=Server.CreateObject("Scripting.FileSystemObject") Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1) do while f.AtEndOfStream = false Response.Write(f.ReadLine) Response.Write("The first four characters in the text file are skipped:
<% Set fs=Server.CreateObject("Scripting.FileSystemObject") Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1) f.Skip(4) Response.Write(f.ReadAll) f.Close Set f=Nothing Set fs=Nothing %>The first line in the text file is skipped:
<% Set fs=Server.CreateObject("Scripting.FileSystemObject") Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1) f.SkipLine Response.Write(f.ReadAll) f.Close Set f=Nothing Set fs=Nothing %>This is all the lines in the text file (with line numbers):
<% Set fs=Server.CreateObject("Scripting.FileSystemObject") Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1) do while f.AtEndOfStream = false Response.Write("Line:" & f.Line & " ") Response.Write(f.ReadLine) Response.Write("The cursor is now standing in position " & f.Column & " in the text file.
") f.Close Set f=Nothing Set fs=Nothing %> <% Dim fs, d, n Set fs=Server.CreateObject("Scripting.FileSystemObject") Set d=fs.GetDrive("c:") n = "Drive: " & d n = n & "The values of the items are:
") a=d.Items for i = 0 To d.Count -1 s = s & a(i) & "The value of the keys are:
") a=d.Keys for i = 0 To d.Count -1 s = s & a(i) & "This page has been visited <%=fcount%> times.
<% Response.Write(Session.SessionID) %> <% response.write("") response.write("Default Timeout is: " & Session.Timeout & " minutes.") response.write("
") Session.Timeout=30 response.write("") response.write("Timeout is now: " & Session.Timeout & " minutes.") response.write("
") %> <% Set fs = Server.CreateObject("Scripting.FileSystemObject") Set rs = fs.GetFile(Server.MapPath("demo_lastmodified.asp")) modified = rs.DateLastModified %> This file was last modified on: <%response.write(modified) Set rs = Nothing Set fs = Nothing %> <% Set FS = Server.CreateObject("Scripting.FileSystemObject") Set RS = FS.OpenTextFile(Server.MapPath("text") & "\TextFile.txt",1) While not rs.AtEndOfStream Response.Write RS.ReadLine Response.Write("This is some text
Example <% Response.Write(Request.QueryString) %>This is some text
ASP Source: <% If Request.Form("txt")<>"" Then Response.Write("You submitted: ") Response.Write(Request.Form) Response.Write("") Response.Write("The information received from the form was:") Response.Write("
") Response.Write("name=" & name) Response.Write("
") Response.Write("The name property's count is: ") Response.Write(Request.QueryString("name").Count) Response.Write("
") Response.Write("First name=" & name1) Response.Write("
") Response.Write("Last name=" & name2) Response.Write("
") end if %> <% Response.Write(Request.Form) %> <% dim fname fname=Request.Form("fname") If fname<>"" Then Response.Write("Hello " & fname & "!The information received from the form above was:
<% If Request.Form("name")<>"" Then Response.Write("") Response.Write("name=" & Request.Form("name")) Response.Write("
") Response.Write("The name property's count is: ") Response.Write(Request.Form("name").Count) Response.Write("
") Response.Write("First name=" & Request.Form("name")(1)) Response.Write("
") Response.Write("Last name=" & Request.Form("name")(2)) Response.Write("
") End if %> <% dim cars cars=Request.Form("cars") %> <% if cars<>"" then Response.Write("Your favorite car is: " & cars & "
") end if %> <% fruits=Request.Form("fruits") %> <% if fruits<>"" then%>You like: <%Response.Write(fruits)%>
<%end if %>You are browsing this site with: <%Response.Write(Request.ServerVariables("http_user_agent"))%>
Your IP address is: <%Response.Write(Request.ServerVariables("remote_addr"))%>
The DNS lookup of the IP address is: <%Response.Write(Request.ServerVariables("remote_host"))%>
The method used to call the page: <%Response.Write(Request.ServerVariables("request_method"))%>
The server's domain name: <%Response.Write(Request.ServerVariables("server_name"))%>
The server's port: <%Response.Write(Request.ServerVariables("server_port"))%>
The server's software: <%Response.Write(Request.ServerVariables("server_software"))%>
All possible server variables:
<% For Each Item in Request.ServerVariables Response.Write(Item & "This is some text
<% If Response.IsClientConnected=true then Response.Write("The user is still connected!") else Response.Write("The user is not connected!") end if %>This page will expire on May 05, 2001 05:30:30!
This page will be refreshed with each access!
This text will be sent to your browser when my response buffer is flushed.
<% Response.Flush %>This is some text I want to send to the user.
No, I changed my mind. I want to clear the text.
<% Response.Clear %>I am writing some text. This text will never be
<%
Response.End
%>
finished! It's too late to write more!
This example demonstrates a link, each time you load the page, it will display one of two links: W3Schools.com! OR Refsnesdata.no! There is a 50% chance for each of them.
ASP can output plain text:
<%response.write("Hello World!")%> <% response.write("This text is styled with the style attribute!
") %> <% if cars<>"" then Response.Write("Your favorite car is: " & cars & "
") end if %> <% var d=new Date() var h=d.getHours() Response.Write("") Response.Write(d) Response.Write("
") if (h<12) { Response.Write("Good Morning!") } else { Response.Write("Good day!") } %> <% i=hour(time) If i < 10 Then response.write("Good morning!") Else response.write("Have a nice day!") End If %> <% i=hour(time) If i = 10 Then response.write("Just started...!") ElseIf i = 11 Then response.write("Hungry!") ElseIf i = 12 Then response.write("Ah, lunch-time!") ElseIf i = 16 Then response.write("Time to go home!") Else response.write("Unknown") End If %> <% d=weekday(Date) Select Case d Case 1 response.write("Sleepy Sunday") Case 2 response.write("Monday again!") Case 3 response.write("Just Tuesday!") Case 4 response.write("Wednesday!") Case 5 response.write("Thursday...") Case 6 response.write("Finally Friday!") Case Else response.write("Super Saturday!!!!") End Select %>This example demonstrates the "Select Case" statement.
You will receive a different greeting based on what day it is.
Note that Sunday=1, Monday=2, Tuesday=3, etc.
<% randomize() r=rnd() If r>0.5 Then response.write("Learn XML!") Else response.write("Learn PHP!") End If %>This example demonstrates a link, when you click on the link it will take you to XML or to PHP. There is a 50% chance for each of them.
ASP Source: <% dim fname fname=Request.QueryString("fname") If fname<>"" Then Response.Write("Hello " & fname & "!" & now()) response.write("
") If h<12 then response.write("Good Morning!") else response.write("Good day!") end if %>Result: <%call vbproc(3,4)%>
Result: <%call jsproc(3,4)%>
Result: <%jsproc(3,4)%>
You can call a procedure like this:
Result: <%call vbproc(3,4)%>
Or, like this:
Result: <%vbproc 3,4%>
Today's date is: <%response.write(date())%>.VBScripts' function WeekdayName is used to get a weekday:
<% response.Write(WeekDayName(1)) response.Write("Abbreviated name of a weekday:
<% response.Write(WeekDayName(1,true)) response.Write("Current weekday:
<% response.Write(WeekdayName(weekday(date))) response.Write("VBScripts' function MonthName is used to get a month:
<% response.Write(MonthName(1)) response.Write("Abbreviated name of a month:
<% response.Write(MonthName(1,true)) response.Write("Current month:
<% response.Write(MonthName(month(date))) response.Write("Countdown to year 3000:
<%millennium=cdate("1/1/3000 00:00:00")%>
It is
<%response.write(DateDiff("yyyy", Now(), millennium))%>
years to year 3000!
It is
<%response.write(DateDiff("m", Now(), millennium))%>
months to year 3000!
It is
<%response.write(DateDiff("ww", Now(), millennium))%>
weeks to year 3000!
It is
<%response.write(DateDiff("d", Now(), millennium))%>
days to year 3000!
It is
<%response.write(DateDiff("h", Now(), millennium))%>
hours to year 3000!
It is
<%response.write(DateDiff("n", Now(), millennium))%>
minutes to year 3000!
It is
<%response.write(DateDiff("s", Now(), millennium))%>
seconds to year 3000!
Syntax for FormatDateTime: FormatDateTime(date,namedformat).
<% response.write(DateAdd("d",30,Date())) %>This example uses DateAdd to calculate a date 30 days from today.
Syntax for DateAdd: DateAdd(interval,number,date).
<% somedate="10/30/99" response.write(IsDate(somedate)) %> <% name = "Bill Gates" response.write(ucase(name)) response.write("A Function procedure can return a result.
ASP can output plain text:
<%response.write("Hello World!")%>ASP can output HTML tags as well as plain text:
<% response.write("ASP can output HTML attributes as well as plain text:
<% response.write("This text is styled.
") %> <% dim name name="Donald Duck" response.write("My name is: " & name) %> <% Dim firstname firstname="Hege" response.write(firstname) response.write("The script above declares a variable, assigns a value to it, and displays the value. Then, it changes the value, and displays the value again.
<% Dim name name="Jan Egil" response.write("My name is: " & name) %> <% Dim famname(5),i famname(0) = "Jan Egil" famname(1) = "Tove" famname(2) = "Hege" famname(3) = "Stale" famname(4) = "Kai Jim" famname(5) = "Borge" For i = 0 to 5 response.write(famname(i) & "