HTML Application and databases - hta

How to access database in HTA files? Or better yet, access any COM?
I'm familiar with AutoIt, AutoHotKey and Windows Script Host. Is there a way to include any of these in an HTA app?

You do it in exactly the same way as you would in VBScript. Below is an example of creating a spreadsheet using Excel.
To access databases, you can use the ADODB object, and to create a database, you would use the ADOX object. You need to know the right connection string for the type of database you need.
<html>
<!-- COMTest.hta -->
<head>
<hta:application
id="oHTA"
border="thick"
borderstyle="raised"
caption="yes"
maximizebutton="no"
minimizebutton="yes"
showintaskbar="yes"
singleinstance="yes"
sysmenu="yes"
version="0.1"
windowstate="normal"
/>
<title>COM Test</title>
<script language="VBScript">
sub say(s)
output.innerHTML = output.innerHTML & s & "<br>"
end sub
sub ComTest()
say "testing COM"
xlFile = "c:\test\ExcelTest.xls"
' use .xslx if you have Office 2007 or greater
set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(xlFile) then
say "deleting test file: " & xlFile
end if
say "creating Excel Application object and workbook"
set oEx = CreateObject("Excel.Application")
set oWb = oEx.Workbooks.Add() ' create a new workbook
set oWs = oWb.Worksheets(1) ' point to first worksheet
oWs.cells(1,1) = "Test Worksheet"
oWs.cells(2,1) = "=now()"
oWs.UsedRange.Columns.AutoFit
say "saving test file: " & xlFile
oEx.DisplayAlerts = false ' if file exists, overwrite it without prompting
oWb.SaveAs xlFile
oEx.Quit
set oEx = nothing
say "done"
end sub
</script>
<style type="text/css">
body {
overflow: auto;
background-color: "blanchedalmond";
}
#output {
color: lightgreen;
background-color: black;
font-family: "Lucida Console";
font-size: 9pt;
padding: 3px;
}
</style>
</head>
<body>
<input type="button" value="test" onclick="ComTest">
<br>
<pre id="output"></pre>
</body>
<script language="vbscript">
sub ShowTitle()
say document.Title
say "command line=" & oHTA.commandLine
end sub
ShowTitle
</script>
</html>

To access the database, you will need the ActiveXObject.
var conn = new ActiveXObject("ADODB.Connection");
var rs = new ActiveXObject("ADODB.Recordset");
conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=handbook.mdb");
rs.Open("select * from faq", conn, 3, 2);
if (!rs.BOF && !rs.EOF) {
questionField.value = rs.fields('question').value;;
answerField.value = rs.fields('answer').value;
}

I took the two answers and merged them as follows:
a) I updated ComTest() from an excel test to access an oracle db
b) ActiveXObject only works for JScript, so I converted it to VBscript as per: http://msdn.microsoft.com/en-us/library/ms756007(v=vs.85).aspx
sub ComTest()
say "testing COM"
dim conn, rs
set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
conn.Open("Provider=OraOLEDB.Oracle;Data Source=XXXX;User ID=XXXX;Password=XXXX")
say "open conn"
rs.Open "select sysdate from dual", conn
say "sqlResult =" & rs.Fields("sysdate").Value
'Close connection and clean up objects
conn.Close
say "close conn"
Set rs = Nothing
Set conn = Nothing
say "done"
end sub

Related

Keeps getting EOF expected error

I have this problem with SOAP that I can't seem to solve.
No matter what I try, then I keep getting this error:
500 - Internal server error. There is a problem with the resource you
are looking for, and it cannot be displayed.
When digging further down the error code I'm told there is a EOF expected error?
Hope that some of you might be able to help me
<%
On Error Resume Next
Dim objXMLHTTP : set objXMLHTTP = Server.CreateObject("Msxml2.XMLHTTP.3.0")
Dim strFunction
Dim strRequest
Dim strResult
Dim strName
Dim strFirstName
Dim strLastname
Dim strAddress
Dim strZipCode
Dim strCity
Dim strTelephone
Dim strTelephone2
Dim strTelephone3
Dim strTelephone4
Dim strEmail
Dim strExtFields
Dim strStdFields
Dim CampaignID
Dim Page
Page = Request.Form("Page")
CampaignID = Request.Form("CampaignID")
StrName = Request.Form("Name")
StrTelephone = Request.Form("Phone")
strRequest = ""
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"">
<Body>
<InsertNewCustomer xmlns=""http://api.ivocall.dk/ivocallservice.asmx"">
<Login>Loginname</Login>
<Password>Password</Password>
<ClientID>1323</ClientID>
<IDPassword>ag4bghsitm8gatddbpt34qjndjrbsla</IDPassword>
<CampaignID>"& campaignid &"</CampaignID>
<Name>"& StrName &"</Name>
<Firstname></Firstname>
<Lastname></Lastname>
<Address></Address>
<City></City>
<ZipCode></ZipCode>
<Telephone>"& StrTelephone &"</Telephone>
<Telephone2></Telephone2>
<Telephone3></Telephone3>
<Telephone4></Telephone4>
<email></email>
<ExtFields>landingpage="& page &"</ExtFields>
<StdFields></StdFields>
<UserName></UserName>
</InsertNewCustomer>
</Body>
</Envelope>"
objXMLHTTP.open "post", "" & "http://api.ivocall.dk/ivocallservice.asmx" & "", False
objXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=UTF-8"
objXMLHTTP.setRequestHeader "Content-Length", Len(strRequest)
objXMLHTTP.setRequestHeader "SOAPAction", "http://www.ivocall.dk/ivocallservice/InsertNewCustomer"
'send the request and capture the result
Call objXMLHTTP.send(strRequest)
strResult = objXMLHTTP.responseText
'display the XML
response.write strResult
response.write strRequest
If Err.Number <> 0 Then
Response.Write (Err.Description)
ELSE
Response.Write ("task done")
Response.End
End If
%>
I really hope some of you can help me out her?
You use inline code-tags.
<%
They do not contain any imported namespaces.
Additionally, you seem to want to copying XML into strRequest, but you're not properly escaping it, plus VB.NET (which is what you're using, not C#) doesn't support multiline strings.
And why do you use
Server.CreateObject("Msxml2.XMLHTTP.3.0")
You can use the normal WebRequest class, instead of an ActiveX-Object. And if you want to do it client-side, you need to use JavaScript (AJAX).
If you're doing a cross-domain request, you need to use CORs (and a browser supporting CORs), or you need to write a proxy that does the request for you.
Additionally, did you try adding a web-reference to your project ?
Visual Studio will automagically download the WSDL and generate the wrapper classes. Why do you want to do it by hand ? ...
Additionally, if you want to embed code in the ASPX page, do it in a "script"-tag using runat="server":
<%# Register TagPrefix="RS" Namespace="Microsoft.ReportingServices.WebServer" Assembly="ReportingServicesWebServer" %>
<%# Page Language="C#" AutoEventWireup="true" Inherits="Microsoft.ReportingServices.WebServer.ReportViewerPage" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<script type="text/C#" runat="server">
protected void SetDocumentMode()
{
if(System.Web.HttpContext.Current == null || System.Web.HttpContext.Current.Request == null || System.Web.HttpContext.Current.Request.Browser == null || System.Web.HttpContext.Current.Request.Browser.Browser == null)
// return "<null>";
return;
if (!StringComparer.OrdinalIgnoreCase.Equals(System.Web.HttpContext.Current.Request.HttpMethod, "GET"))
// return "<notget>";
return;
// fu IE 11
if(System.Web.HttpContext.Current.Request.Browser.Browser == "IE" || System.Web.HttpContext.Current.Request.Browser.Browser == "InternetExplorer")
{
if(System.Globalization.CultureInfo.InvariantCulture.CompareInfo.IndexOf(System.Convert.ToString(System.Web.HttpContext.Current.Request.QueryString), "stylesheet", System.Globalization.CompareOptions.IgnoreCase) == -1 )
{
System.Web.HttpContext.Current.Response.Write(#"<meta http-equiv='X-UA-Compatible' content='IE=5'>
");
//return "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=5\">"; // IE5-Quirks when no custom stylesheet (=not in iframe)
}
else
System.Web.HttpContext.Current.Response.Write("<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>");
// return "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">"; // Switch to Standards mode when a custom stylesheet is set(=in iframe)
}
// return "<not ie: " + System.Web.HttpContext.Current.Request.Browser.Browser + ">";
//return "";
}
</script>
[...]
<%SetDocumentMode(); %>
Are you actually using ASP instead of ASP.NET ?

Need Replacement for MS Index Service on Server 2012 with Classic ASP (VB)

I have just migrated a website from Server 2003 to Server 2012, and MS Indexing service is not available.
In doing some research, I found that MS Search Service is the 'replacement,' and, as such, I installed it on Server 2012. Beyond this, I haven't found what ASP-Classic (VB) code would be necessary to enable the new Search Service to catalog my documents, as Indexing Service did.
Does MS Search Service have the capability and flexibility to catalog and search documents, and return results in the same way that MS Indexing Service did?
Below is an example of the code that currently calls the MS Indexing Service (on the Windows 2003 server):
<%
Dim strQuery ' The text of our query
Dim objQuery ' The index server query object
Dim rstResults ' A recordset of results returned from I.S.
Dim objField ' Field object for loop
Dim objUtility
' Retreive the query from the querystring
strQuery = Request.QueryString("CiRestriction")
if strQuery <> "" then
if Request.QueryString("ExactPhrase") = "Yes" then
strQuery = """" & strQuery & """"
end if
end if
' If the query isn't blank them proceed
If strQuery <> "" Then
' Create our index server object
Set objQuery = Server.CreateObject("IXSSO.Query")
' Set its properties
objQuery.Catalog = "Test_Docs" ' Catalog to query
objQuery.MaxRecords = 75 ' Max # of records to return
objQuery.SortBy = "Rank[d], size"
objQuery.Columns = "Characterization, DocTitle, Directory, Filename, Path, Rank, Size, Vpath, Write"
' Build our Query: Hide admin page and FPSE pages
'strQuery = "(" & strQuery & ")" _
' & " AND NOT #filename = *admin*" _
' & " AND NOT #path *\_vti_*"
' Uncomment to only look for files modified last 5 days
'strQuery = strQuery & " AND #write > -5d"
' To set more complex scopes we use the utility object.
' You can call AddScopeToQuery as many times as you need to.
' Shallow includes just files in that folder. Deep includes
' subfolders as well.
'
Set objUtility = Server.CreateObject("IXSSO.Util")
objUtility.AddScopeToQuery objQuery, "d:\test_shares\test_docs", "deep"
objQuery.Query = strQuery ' Query text
Set rstResults = objQuery.CreateRecordset("nonsequential") ' Get a recordset of our results back from Index Server
' Check for no records
If rstResults.EOF Then
Response.Write "Sorry. No results found."
Else
' Print out # of results
Response.Write "<p><strong>"
Response.Write rstResults.RecordCount
Response.Write "</strong> results found:</p>"
' Loop through results
Do While Not rstResults.EOF
' Loop through Fields
' Pretty is as pretty does... good enough:
%>
<%KSize=formatnumber(rstResults.Fields("size"))
KSize= round(KSize/1024,0)%>
<p>
<%'test below using PoorMansIsNull function%>
<% If PoorMansIsNull(rstResults.Fields("DocTitle")) Or rstResults.Fields("DocTitle")="" Then %>
<%= PathToVpath(rstResults.Fields("filename")) %>
<% Else %>
<font size="3"><%= rstResults.Fields("DocTitle") %></font>
<% End If %>
<br><%= rstResults.Fields("Characterization") %><br>
<font color="#009900"><%= PathToVpath(rstResults.Fields("path")) %> - <%= KSize %>k<br /></font>
</p>
<%
' Move to next result
rstResults.MoveNext
Loop
rstResults.MoveFirst
Response.Write "<pre>"
'Response.Write rstResults.GetString()
Response.Write "</pre>"
End If
' Kill our recordset object
Set rstResults = Nothing
Set objUtility = Nothing
Set objQuery = Nothing
End If
%>
</body>
</html>
<%
Function PathToVpath(strPath)
Const strWebRoot = "d:\test_shares\test_docs\"
Dim strTemp
strTemp = strPath
strTemp = Replace(strTemp, strWebRoot, "\")
strTemp = Replace(strTemp, "\", "/")
PathToVpath = strTemp
End Function
%>
And, the results would be listed, per document (the name of the document, with excerpt from document text, along with title, size), as illustrated below:
Thanks for any leads and/or alternatives.
This example is in fact incorrect. It does not work. The following code:
objRecordSet.Open "SELECT Top 20 " & _
"System.ItemPathDisplay " & _
",System.ItemName " & _
",System.Size " & _
"FROM SYSTEMINDEX", objConnection & _
"WHERE SCOPE='file:E:\MANIF\DAAP\AC'"
Should really use the connection object at the end of the query. Spent a few hours wondering why the WHERE clause was not working.
objRecordSet.Open "SELECT Top 20 " & _
"System.ItemPathDisplay " & _
",System.ItemName " & _
",System.Size " & _
"FROM SYSTEMINDEX " & _
"WHERE SCOPE='file:E:\MANIF\DAAP\AC'", objConnection
This should help all who are having the same difficulty.
I'm facing the same problem. I've found a MS guide about this issue: Querying the Index with Windows Search SQL Syntax.
I've tested this ASP (Classic) code and ran ok:
<html>
<body>
Results<br>
<ol>
<%
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Open "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"
'change directory on scope clause
objRecordSet.Open "SELECT Top 20 " & _
"System.ItemPathDisplay " & _
",System.ItemName " & _
",System.Size " & _
"FROM SYSTEMINDEX" & _
" WHERE SCOPE='file:E:\MANIF\DAAP\AC'", objConnection
objRecordSet.MoveFirst
Do Until (objRecordSet.EOF)
%>
<li>
<strong>Path Display:</strong><%=objRecordSet("System.ItemPathDisplay")%><br>
<strong>Name:</strong><%=objRecordSet("System.ItemName")%><br>
<strong>Size:</strong><%=objRecordSet("System.Size")%><br>
<hr>
</li>
<%
objRecordSet.MoveNext
Loop
objRecordSet.Close
Set objRecordSet = Nothing
objConnection.Close
Set objConnection = Nothing
%>
</ol>
</body>
</html>
Other alternatives:
Try to register asp dll in windows server. For I could see, nobody related success on this approch. See this post;
Create a VM a previous windows version to support your asp. See this MS article.
Hope it could help you.

Server.CreateObject(“Scripting.FileSystemObject”) issue - Object required:Server (code:0) ASP/VBscript

I want to create a file on my server, and then, write datas in
<script runat="server" language="VBScript">
Function saveData()
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("ecr.txt", 8,true)
f.WriteLine("osgfouds")
End Function
</script>
I get an error in my browser telling me 'object required: server' at the 'Server.CreateObject' line
Server.createobject would be for VBScript/ASP scripts on the server itself. The client browser would not be able to support Server for this reason.
As an added note. You need to Close out your file object(f) because it will keep the file open and cause errors when you try to write to it again. Also, I added the ForAppending bit so that you can specify it in your fso.opentextfile.
So to fix your script:
<script runat="server" language="VBScript">
Function saveData()
Const ForReading As String = 1
Const ForWriting As String = 2
Const ForAppending As String = 8
Dim fso as Object
Dim f as Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("ecr.txt", ForAppending, true)
f.WriteLine("osgfouds")
f.Close
End Function
</script>
EDIT
This is an updated question from -> Here
EDIT
Ok, looking at your previous question and this one. Here's the thing: ASP runs at the server level and Loads vbscript into the website interface. Vbscript attached directly to ASP will run at the server level:
e.g.
<%
Const ForAppending = 8
dim fn,fp,fpn,wl,fulltext : fn = replace(formatdatetime(Now, 2), "/", "-") & ".txt"
Dim fso, msg : fp = "C:\Users\...\Desktop\Logs\"
fpn = fp & fn
dim sep : sep = "==========================================================================="&vbcrlf
dim ssep : ssep = vbcrlf & "--------------------------------------"
fso = CreateObject("Scripting.FileSystemObject")
dim IPAddress, HostName, LUname
IPAddress = Request.ServerVariables("remote_addr")
If (fso.FileExists("C:\Users\...\Desktop\Logs\" & fn)) Then
dim inSession,newuser
wl = fso.OpenTextFile(fpn, ForAppending, True)
inSession = fso.OpenTextFile("C:\Users\...\Desktop\Logs\" & fn, 1)
fulltext = inSession.ReadAll
'.....Code continues'
%>
So if your trying to activate a click event and attach it to a VBScript to write to a file on the server end, this will not work, because the vbscript will attempt to write it to the client regardless.
The proper way for a asp/vbscript to be designed for user entry updates needs to be executed in the following fashion:
BROWSER - click -> request to server -> server processes request -> serves new page -> BROWSER
Evidence provided -> Here
However, you can still utilize an XMLHTTPRequest or Ajax/Javascript to activate a script. Actually, funny thing is, I just asked about how to execute a very basic script like this recently. So here's how to do it:
You have your HTML file(whatever.html):
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script type ="text/javascript" >
$(function () {
$("#button").click(function () {
$.get("test2.aspx", {
loadData: "John"
})
.done(function (data) {
if (data === "Fail") {
alert("Logging Failed!");
} else {
alert("Logged Success!");
}
})
.fail(function () {
alert("error");
});
});
});
</script>
</head><body>
<input type="button" id="button" value="Ecriture"></body>
And you have your ASPX File (test2.aspx):
<%# Page Language="VB" %>
<%
Dim LogData As String : LogData = Request.Params("loadData")
Dim SaveFile As String
Const ForReading As Integer = 1
Const StorageDirectory = "C:\Users\...\Desktop\Logs\serverlog.txt"
Const ForWriting As Integer = 2
Const ForAppending As Integer = 8
If Len(LogData) = 0 Then LogData = "{EMPTY STRING}"
Dim fso As Object
Dim f As Object
fso = CreateObject("Scripting.FileSystemObject")
f = fso.OpenTextFile(StorageDirectory, ForAppending, True)
f.WriteLine("New Entry:" & LogData)
f.Close()
If Err.Number <> 0 Then
SaveFile = "Fail"
Else
SaveFile = "Success"
End If
Response.Write(SaveFile)
%>
NOTE
The StorageDirectory must be a shared network folder so that the server can maintain updating the file.
I've tested this code and it works. Good Luck
This will work in VB.NET. Try this
Dim oFs
Dim vSharePath
Dim vFolder
Dim vPath
Dim objTStream
vSharePath = ConfigurationManager.AppSettings("NetworkPath").ToString
vFolder = Year(Date.Now) & Month(Date.Now).ToString & Date.Now.Hour.ToString & Date.Now.Second.ToString
vPath = vSharePath & "\" & vFolder
oFs = Server.CreateObject("Scripting.FileSystemObject")
If Not (oFs.FolderExists(vPath)) Then
Call oFs.CreateFolder(vPath)
objTStream = oFs.CreateTextFile(vPath & "\test.txt", True)
'Write some text to the file
objTStream.WriteLine("Hello World!")
objTStream.WriteLine()
objTStream.WriteLine("This is my first text file!")
'Close the TextStream object
objTStream.Close()
'Free up resources
objTStream = Nothing
End If
oFs = Nothing
http://webcheatsheet.com/asp/filesystemobject_object.php

Application object restrictions in VBScript

I have to modify a page that is using VBScript.
I have a problem to set local variable to Application object in a function. The code below, in the getObjectSchema function, generates an error:
Set LocalSchema = Application("ObjectSchema")
While the code below, in the main body (outside of any functions) works absolutely fine:
Set Schema = Application("ObjectSchema")
Does anybody knows what is wrong? Are there any limitations for access to Application objects from a function?
Here is the complete code
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
.style1 {
width: 87px;
}
</style>
</head>
<body>
<script type="text/vbscript">
Option Explicit
Dim ObjectSchema
Dim strXML
Dim strXML1
Dim sUserId
On Error Resume Next
Function GetUserID()
GetUserID = "{3450E0D8-EE30-48EE-B63F-486506AD1D97}"
End Function
Function getObjectSchema()
Dim LocalSchema
Set LocalSchema = Application("ObjectSchema")
If LocalSchema Is Nothing Then
Set LocalSchema = CreateObject("Scripting.Dictionary")
End if
If LocalSchema.Exists(sUserId) Then
strXML = LocalSchema.Item(sUserId)
Else
strXML = "<head><title>Title</title></head><head1><title1>Title1</title1></head1>"
LocalSchema.Add sUserId, strXML
Set Application("ObjectSchema") = LocalSchema
End if
getObjectSchema = strXML
End Function
sUserId = GetUserID()
strXML = ""
strXML1 = ""
strXML = getObjectSchema()
strXML1 = getObjectSchema()
strXML = getObjectSchema()
strXML1 = getObjectSchema()
Dim Schema
Set Schema = Application("ObjectSchema")
If Schema Is Nothing Then
Set Schema = CreateObject("Scripting.Dictionary")
End if
If Schema.Exists(sUserId) Then
strXML = LocalSchema.Item(sUserId)
Else
strXML = "<head><title>Title</title></head><head1><title1>Title1</title1></head1>"
Schema.Add sUserId, strXML
Set Application("ObjectSchema") = Schema
End if
strXML1 = strXML
</script>
</body>
</html>
Try a null check before setting LocalSchema:
If Not Application("ObjectSchema") Is Nothing Then
Set LocalSchema = Application("ObjectSchema")
End If
UPDATE
You have this running in a <script type="text/vbscript"> element, which I think means it's interpreted by the browser (specifically Internet Explorer because of the vbscript business).
The browser may not have a concept of an Application object.
Try enclosing your code in a code-block (to run it at the server) instead:
<body>
<%
Option Explicit
Dim ObjectSchema
Dim strXML
Dim strXML1
Dim sUserId
...
strXML1 = strXML
%>
</body>

How to display four images with rotate effect from folder using classic ASP?

I have one folder in which my images get stored, now I want to create a slideshow such as the one here.
I tried the following code (but it displays just single image on page refresh):
<%#LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<html>
<head>
<%
Function RandomImage(strPath,strDefault)
On Error Resume Next
'response.Write("HI")
Randomize Timer
' declare all variables
Dim objFSO, objFolder, objFiles, objFile
Dim strFiles, strImages, strPhysical, strFile
' this constant has the names of valid image file name
' extensions and can be modified for more image types
Const strValid = ".gif.jpg.png"
' make sure we have a trailing slash in the path
If Right(strPath,1) <> Chr(47) Then strPath = strPath & Chr(47)
' get the physical path of the folder
strPhysical = Server.MapPath(strPath)
' get a File System Object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' create a folder object
Set objFolder = objFSO.GetFolder(strPhysical)
' get the files collection
Set objFiles = objFolder.Files
' enumerate the files collection looking for images
For Each objFile in objFiles
strFile = LCase(objFile.Name)
If Instr(strValid,Right(strFile,4)) Then
' add vaild images to a string of image names
strFiles = strFiles & strFile & vbTab
End If
Next
' split the image names into an array
strImages = Split(strFiles,vbTab)
' if we have an array...
If UBound(strImages) > 1 Then
' get a random name
RandomImage = strPath & strImages(Int(Rnd(1)*UBound(strImages)))
Else
' otherwise return the default
RandomImage = strDefault
End If
End Function
%>
<%
strImg = RandomImage("./retailers/","./retailers/A1-Supplements.jpg")
strsplit = split(strImg,"/")
' Response.Write(strsplit(2))
' Response.Write("rahul =" &strImg)
' d_desc = Split(Request.Form("strImg"),"/")
' Name of text file to search:
strFileName = "saveimagename.txt"
' Text to search for:
strSearchText = strsplit(2)
'response.Write(strSearchText)&"<br/>"
'response.end()
' Create an instance of the the File System Object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' Open the file
Set objTextFile = objFSO.OpenTextFile(Server.MapPath(strFileName))
URLString = ""
Do While Not objTextFile.AtEndOfStream
strReadLineText = objTextFile.ReadLine
'response.Write(strReadLineText & "<br>")
If strReadLineText<>"" then
If Instr(strReadLineText,",")>0 then
strReadLineTextArr=split(strReadLineText,",")
URLString=strReadLineTextArr(1)
end if
end if
If InStr(lcase(strReadLineText), lcase(strSearchText)) > 0 Then
Exit Do
End If
Loop
strSearchText=""
' Close and release file references
objTextFile.Close
Set objTextFile = Nothing
Set objFSO = Nothing
'Response.Write URLString
'Response.End()
%>
</head>
<body>
<div align="center" style="width:800px; float:left;">
<center>
<table border="0" width="800px">
<tr>
<td>
</td>
<td bgcolor="#000" align="center" style="border:none;">
<img src="<%=strImg%>" onClick="<%=URLString%>" border="0">
</td>
<td>
</td>
</tr>
</table>
</center>
</div>
</body>
</html>
Please help me.
Try to accomplish this from the server-side is very difficult. You can only assign the images once and the only way to change them is for your user to refresh the page.
What you need to do is create your slideshow on the client-side with JavaScript. Fortunately, there are lots of libraries that can help you. Search for slideshows and jquery and you should be able to find what you need. Here's one such link.
You definitely want to do this on the client side using jQuery. It will be more efficient for your end users and less server interaction.
Here are a few good slideshows with tutorials on how to implement them:
http://speckyboy.com/2009/06/03/15-amazing-jquery-image-galleryslideshow-plugins-and-tutorials/

Resources