Replace href several strings in vb.net asp.net - asp.net

I need to find several hrefs in html like this:
<table>
<tr><td>link1</td>
<td><img src="image.jpg" /></td>
</tr>
</table>
Once found I need to add (replace) to each href something like this:
?ID=1
therefore the html should turn out like this:
<table>
<tr><td>link1</td>
<td><img src="image.jpg" /></td>
</tr>
</table>
Any help would be appreciated, thanks, Mike.

Here's the new code:
Shared Function AdjustURL(ByVal psInput As String, ByVal psAppend As String) As String
Dim sOrig As String = " " & psInput 'Prepending a space (browser will ignore) in case the first character is a link.
Dim sOutput As String = ""
Dim iEnd As Integer = -1, iQuestion As Integer = -1
While sOrig.Length > 0
sOutput &= sOrig.Substring(0, 1)
sOrig = sOrig.Substring(1)
iEnd = -1
If sOrig.StartsWith("<a href=") Then 'Is this a safe assumption, what if it's not an <a> or href isn't next after only one space?
If sOrig.StartsWith("<a href=""") Then
iEnd = InStr(10, sOrig, """") 'URL ends with a Quote
Else
iEnd = InStr(9, sOrig, " ") 'URL ends with a Space - are there other possibilities?
End If
iQuestion = InStr(sOrig, "?")
If iQuestion > iEnd Then iQuestion = -1
sOutput &= sOrig.Substring(0, iEnd - 1) & IIf(iQuestion > -1, "?", "&") & psAppend
sOrig = sOrig.Substring(iEnd - 1)
End If
End While
Return sOutput
End Function
Call:
Dim sHTML As String = "<table> <tr><td>link1</td> <td><img src=""image.jpg"" /></td> </tr> </table>"
Response.Write(Class1.AdjustURL(sHTML, "ID=1"))
Result:
<table> <tr><td>link1</td> <td><img src="image.jpg" /></td> </tr> </table>
I'm sure there will be other replacements you will discover over time as users enter things. I'd definitely recommend replacing <script with something like <span style=display:none to avoid javascript injection. You'll also want to be sure to avoid SQL injection before writing this to your database.

Related

How to pass value parameter in url that cannot excecute directly in url?

So i have this program that sending notification value to other page and show the notification, but the problem is you can edit the value in the url,
If lngErrNo <> 0 Then
response.write "Error while update Product."
response.end
Else
v_strMsg = "Edit Kelipatan Jumlah Pesanan Berhasil!"
Response.Redirect "global_notification.asp?strMsg=" & v_strMsg
End If
the problem is you can edit v_strMsg in url for the example abc.com/global_notification.asp?strMsg= "anything you can edit the value here", and the display page is look like this
<body>
<table class="1" width=70% cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" background="images/bgtable.gif"><div align="left" class="fontwhiteheader13">
ATTENTION!!</div>
</td>
</tr>
<tr>
<td valign="top"><table width=100% height="360" cellpadding="2" cellspacing="2" bgcolor="white">
<tr>
<td align=center class="fontblueheader13"><%=Request.QueryString("strMsg")%>
</td>
</tr>
</table></td></tr></table>
</body>
any possible way to sending the value without changing it to POST metod? i try htmlEncode but v_strMsg still can be edited in url, any suggestion?
You need a signed URL.
A signed URL includes a digital signature that proves the request was generated by the server.
The first thing you need to do is create a secret key:
' Generate your own key from:
' https://www.allkeysgenerator.com/Random/Security-Encryption-Key-Generator.aspx
Const secret_key = "G+KbPeShVmYq3s6v9y$B&E)H#McQfTjW"
In this example it's a 256 bit key.
You also need a hashing function:
hash.asp
<%
' Might as well store the secret key constant in this file:
Const secret_key = "G+KbPeShVmYq3s6v9y$B&E)H#McQfTjW"
Function Hash(ByVal Input, HashAlgorithm)
' Select the System.Security.Cryptography value.
Select Case uCase(HashAlgorithm)
Case "MD5"
HashAlgorithm = "MD5CryptoServiceProvider"
Case "SHA1"
HashAlgorithm = "SHA1CryptoServiceProvider"
Case "SHA2","SHA256"
HashAlgorithm = "SHA256Managed"
Case "SHA384"
HashAlgorithm = "SHA384Managed"
Case "SHA5","SHA512"
HashAlgorithm = "SHA512Managed"
Case Else
HashAlgorithm = "SHA1CryptoServiceProvider"
End Select
' Convert the input to bytes if not already.
If NOT VarType(Input) = 8209 Then
Dim utf8 : Set utf8 = Server.CreateObject("System.Text.UTF8Encoding")
Input = utf8.GetBytes_4(Input)
Set utf8 = Nothing
End If
' Perform the hash.
Dim hAlg : Set hAlg = Server.CreateObject("System.Security.Cryptography." & HashAlgorithm)
Dim hEnc : Set hEnc = Server.CreateObject("MSXML2.DomDocument").CreateElement("encode")
hEnc.dataType = "bin.hex"
hEnc.nodeTypedValue = hAlg.ComputeHash_2((Input))
Hash = hEnc.Text
Set hEnc = Nothing
Set hAlg = Nothing
End Function
%>
Now you're ready to sign your URL with a digital signature.
' Be sure to include "hash.asp"
' Your message:
v_strMsg = "Edit Kelipatan Jumlah Pesanan Berhasil!"
' A unix timestamp:
v_uts = DateDiff("s","1970-01-01 00:00:00",Now())
' NOTE: Your servers timezone should be set to UTC to generate a true unix timestamp,
' but it doesn't really matter, as long as "global_notification.asp" is on the same
' server, or a server set to the same timezone as the page you're generating the
' signature from.
' Now we create the signature as so:
v_signature = Hash(v_strMsg & v_uts & secret_key,"SHA256")
' Finally, redirect to "global_notification.asp"
Response.Redirect "global_notification.asp?strMsg=" & Server.URLEncode(v_strMsg) & "&ts=" & v_uts & "&signature=" & v_signature
Example redirect:
global_notification.asp?strMsg=Edit+Kelipatan+Jumlah+Pesanan+Berhasil%21&ts=1612794802&signature=61016c0a0460902cc4a19f092dcbb4fd818aa9c88d2631e087868253e73983da
Now to validate the signature on global_notification.asp:
<!--#include file = "hash.asp" -->
<%
Dim v_strMsg, v_uts, v_signature, v_uts_now
v_strMsg = Request.QueryString("strMsg")
v_uts = Request.QueryString("ts")
v_signature = Request.QueryString("signature")
' Do some basic validation first.
If v_signature = "" Then
Response.Write "Missing Signature"
Response.End()
ElseIf v_uts = "" Then
Response.Write "Missing Timestamp"
Response.End()
ElseIf NOT Len(v_signature) = 64 Then
Response.Write "Invalid Signature"
Response.End()
ElseIf NOT (IsNumeric(v_uts) AND Len(v_uts) = 10) Then
Response.Write "Invalid Timestamp"
Response.End()
End If
' Validate the signature. To do this, we simply recreate what we're expecting the signature
' to be, and compare it to the one being passed.
If NOT Hash(v_strMsg & v_uts & secret_key,"SHA256") = v_signature Then
Response.Write "Invalid Signature"
Response.End()
End If
' Now let's set an expiration period for the link, say 30 seconds? (or 86400 seconds for a day, 604800 for a week etc).
v_uts = Int(v_uts) + 30
v_uts_now = DateDiff("s","1970-01-01 00:00:00",Now())
If v_uts_now >= v_uts Then
Response.Write "Expired Link"
Response.End()
End If
' At this point, everything is good.
' Go ahead and display the message:
%>
<body>
<table class="1" width="70%" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" background="images/bgtable.gif"><div align="left" class="fontwhiteheader13"> ATTENTION!!</div></td>
</tr>
<tr>
<td valign="top"><table width="100%" height="360" cellpadding="2" cellspacing="2" bgcolor="white">
<tr>
<td align=center class="fontblueheader13"><%=v_strMsg%></td>
</tr>
</table></td>
</tr>
</table>
</body>
Now if you try and change the message (or the timestamp) you'll get an Invalid Signature error. The only way to generate a valid working link is to know the secret key, which of course is hidden.

ADODB, VBScript, ASP, SELECT not working with WHERE

My SELECT statement works until I add a WHERE parameter.
When I have the WHERE parameter added I get a 500 error.
Again, This works correctly unless I add a WHERE parameter to the select statement.
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
Dim db_path
Dim db_dir
db_dir = Server.MapPath("/private") & "\"
db_path = db_dir & "Database.mdb"
conn.Open db_path
set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT DISTINCT Group, Finish FROM Parts WHERE Group = 'Exhaust'"
rs.Open sql, conn
%>
<table border="1" width="100%">
<%response.write(sql)%>
<tr>
<%for each x in rs.Fields
response.write("<th>" & x.name & "</th>")
next%>
</tr>
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
<td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close%>
</table>
</body>
</html>
I fixed it.
It works if I change the select statement to this:
sql="SELECT DISTINCT Group, Finish FROM Parts WHERE (((Group)='Exhaust'));"

Trouble passing results from DataReader to textbox

I am making an admin section that will allow access to several small SQL tables in my project.
I have repeaters set up to show my lists with a button to bring up a Modal for adding a new entry or editing an existing one. The code behind stores a value from the selected row, and then I would like to query my SQL Class to return a value to fill my text boxes. The code works back to the SQL Class and I can display a message box and get the proper results. I can't however get it to pass the value if the query back to the VB page to fill the text boxes.
Here is the Repeater
<%--Employee Repeater--%>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<HeaderTemplate>
<table class="display" id ="employeeList">
<thead>
<tr>
<th>
Name
</th>
<th>
Email
</th>
<th>
Update
</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%# Eval("name")%>
</td>
<td>
<%# Eval("email")%>
</td>
<td>
<asp:Button ID="cmdEditName" runat="server" Text="Edit/Delete" CommandArgument= '<%#Databinder.Eval(Container.DataItem, "id")%>' OnClick="EditName"/>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
My Code Behind
'Open Name Modal bound to repeater
Public Sub EditName(ByVal sender As Object, ByVal e As System.EventArgs)
Dim wLink As New Button
Edit = True
wLink = DirectCast(sender, Button)
txtEditId.Text = wLink.CommandArgument
SQL.RunReader("SELECT name from Admin_Contacts WHERE Admin_Contacts.id = '" & txtEditId.Text & "' ")
txtEditName.Text = results
SQL.RunReader("SELECT email from Admin_Contacts WHERE Admin_Contacts.id = '" & txtEditId.Text & "' ")
txtEditEmail.Text = results
ModalName.Show()
End Sub
And the code in my SQL Class
Public Function RunReader(ByVal Query As String) As String
Dim results As String = ""
Try
SQLCon.Open()
SQLCmd = New SqlCommand(Query, SQLCon)
Dim R As SqlDataReader = SQLCmd.ExecuteReader
While R.Read
results = (R(0))
'MsgBox is just to show that I am getting results
MsgBox(results)
End While
SQLCon.Close()
Catch ex As Exception
MsgBox(ex.Message)
If SQLCon.State = ConnectionState.Open Then
SQLCon.Close()
End If
End Try
Dim results = SQL.RunReader("SELECT name from Admin_Contacts WHERE Admin_Contacts.id = '" & txtEditId.Text & "' ")
txtEditName.Text = results
Complete the runreader function with return statement
Public Function RunReader(ByVal Query As String) As String
Dim results As String = ""
Try
SQLCon.Open()
SQLCmd = New SqlCommand(Query, SQLCon)
Dim R As SqlDataReader = SQLCmd.ExecuteReader
While R.Read
results = (R(0))
'MsgBox is just to show that I am getting results
MsgBox(results)
End While
SQLCon.Close()
Catch ex As Exception
MsgBox(ex.Message)
If SQLCon.State = ConnectionState.Open Then
SQLCon.Close()
End If
End Try
Return results
End Function
Then call this method as
Dim results = SQL.RunReader("SELECT name from Admin_Contacts WHERE Admin_Contacts.id = '" & txtEditId.Text & "' ")

Adding an ASP:DropDownList to select upload folder for ASPxUploadControl

I have a web form that uses a DevExpress ASPxUploadControl (v 8.3) to let our users upload documents to our server. I'm working on an enhancement that will allow them to select an upload folder for the document. These are not physical folders, but logical folders. I've added an ASP:DropDownList to the form, which I populate from the database with the names of the folders that user has set up. If the user selects the folder and then the attachment everything works fine. However, if they select the file to upload and then the folder, the file is uploaded automatically once the file has been selected, rather than waiting for them to click the Upload link. This does not allow them to change if they've selected the wrong document. Also, the old (last) value selected from the dropdownlist is used - it is not being updated to reflect the new choice I suspect there is a clash between server-side events and client-side events. Following is the relevant code. How can I prevent the page from automatically uploading the document?
Thanks!
Mike
<td class="style6" valign="middle">
<asp:Panel ID="Panel3" colspan="2" runat="server" Height="83px" Width="125px"
Style="margin-top: 0px">
<dxuc:ASPxUploadControl ID="uplImage" runat="server"
ClientInstanceName="uploader" Font-Size="Medium" Height="84px"
OnFileUploadComplete="uplImage_FileUploadComplete" ShowUploadButton="True"
Size="50" style="margin-top: 0px; margin-right: 2px;">
<ValidationSettings AllowedContentTypes="image/jpeg,image/gif,image/pjpeg,application/pdf,application/rtf,application/msword,application/vnd.ms-excel,application/csv,text/plain,text/csv,text/richtext,text/rtf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, audio/wav" MaxFileSize="4096000">
<ErrorStyle Font-Size="Smaller" />
</ValidationSettings>
<ClientSideEvents FileUploadComplete="function(s, e) {
if(e.isValid)
{
if(e.errorText != ''){
alert(e.errorText);
} else {
alert(e.callbackData);
}
}
}" />
<ValidationSettings AllowedContentTypes="image/jpeg, image/gif, image/pjpeg, application/pdf, application/rtf, application/msword, application/vnd.ms-excel, application/csv, text/plain, text/csv, text/richtext, text/rtf, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, audio/wav"
MaxFileSize="4096000">
<ErrorStyle Font-Size="Smaller" />
</ValidationSettings>
<ClientSideEvents FilesUploadComplete="function(s, e) {}" FileUploadComplete="function(s, e) {
if(e.isValid)
{
if(e.errorText != ''){
alert(e.errorText);
} else {
alert(e.callbackData);
}
}
}" FileUploadStart="function(s, e) {}" />
</dxuc:ASPxUploadControl>
</asp:Panel>
</td>
</tr>
<tr>
<td colspan="2" class="txtnote" align="center" style="height: 18px">
Allowed file types: jpeg, gif, pdf, rtf, doc, docx, txt, csv, xls, xlsx, wav
</td>
</tr>
<tr>
<td colspan="2" class="txtnote" align="center" style="height: 10px">
Maximum file size: 4Mb
</td>
</tr>
<tr>
<td></td>
<td>
<input id="chkPrivate" name="chkPrivate" value="1" type="checkbox"/>Private
(checking Private prevents Mgmt Co &Assn from viewing attachment via client
login.)</td></tr>
<tr class="aligncenter">
<th class="style5" align="center" colspan="2">
</th>
</tr>
<tr class="aligncenter">
<th class="style5" align="center" colspan="2">
<asp:Panel ID="Panel2" runat="server" Height="50px" Width="125px">
<%--<dxe:ASPxButton ID="Button1" runat="server" Font-Size="Medium" Text="Cancel">
<Paddings PaddingLeft="10px" PaddingRight="10px" />
</dxe:ASPxButton>--%>
<input type="button" id="btnReturn" class="frmBtnCommon" value="Back To Case" onclick="ReturnToCase();" />
</asp:Panel>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim DAL As New DataAccessLayer
Dim dtFolders As New DataTable
GlobalVar.LoadData(Session("UserPKey"))
Session("CurrentPage") = "CaseAttchmt.aspx"
If Session("LoggedOn") = True And GlobalVar.ConnectString <> "" Then
CSSDefaultHTML = Session("CSS_Default")
DefaultIPHTML = Application("DefaultIP")
End If
SelKey = Request.QueryString("Case")
Header1.ConnectionStr = GlobalVar.ConnectString
Header1.HDLawFirm = GlobalVar.LawFirmDir
Header1.InsertHeader("Add File to a Case", 0, 0, SelKey, "width=100% align=center")
ClientKey = Session("ClientKey")
UploadDirectory = GlobalVar.LawFirmDir & "AttachFiles/Case" & Trim(Str(SelKey)) & "/"
If System.IO.Directory.Exists(GlobalVar.LawFirmDir & "AttachFiles/") = False Then
System.IO.Directory.CreateDirectory(GlobalVar.LawFirmDir & "AttachFiles")
End If
If System.IO.Directory.Exists(GlobalVar.LawFirmDir & "AttachFiles/Case" & Trim(Str(SelKey))) = False Then
System.IO.Directory.CreateDirectory(GlobalVar.LawFirmDir & "AttachFiles/Case" & Trim(Str(SelKey)))
End If
GlobalVar.SaveData(Session("UserPKey"))
dtFolders = DAL.GetClientFolders(Session("ClientKey"))
ddlFolders.DataSource = dtFolders
Dim lstFolders As ListItem
Dim i As Integer
Dim intValue As Integer
Dim strText As String
If Not Page.IsPostBack Then
ddlFolders.Items.Clear
intValue = 0
strText = "Attachments"
lstFolders = New ListItem(strText, intValue)
ddlFolders.Items.Add(lstFolders)
For i = 0 to dtFolders.Rows.Count - 1
intValue = dtFolders.Rows(i).Item("pKey")
strText = dtFolders.Rows(i).Item("FolderName")
lstFolders = New ListItem(strText, intValue)
ddlFolders.Items.Add(lstFolders)
Next
ddlFolders.SelectedIndex = 0
Session("FolderKey") = 0
End If
End Sub
Protected Function SavePostedFile() As String
Dim filename As String = ""
Dim tempFileName As String = ""
SelKey = Session("SelKey")
If Len(Trim(Session("ClientKey"))) = 4 then
UploadDirectory = "~/DATA/AR00" & Session("ClientKey") & "/AttachFiles/Case" & Trim(Str(SelKey)) & "/"
Else
UploadDirectory = "~/DATA/" & Trim(Session("LawFirm")) & "/AttachFiles/Case" & Trim(Str(SelKey)) & "/"
End If
filename = Trim(uplImage.FileName)
If filename <> "" Then
tempFileName = MapPath(UploadDirectory) & filename
uplImage.SaveAs(tempFileName)
End If
Return tempFileName
End Function
Protected Sub uplImage_FileUploadComplete(ByVal sender As Object, ByVal e As FileUploadCompleteEventArgs)
Dim FileExists As Boolean = False
UploadDirectory = "~/DATA/" & Trim(Session("LawFirm")) & "/AttachFiles/Case" & Trim(Str(Session("SelKey"))) & "/"
Dim FilePath As String = MapPath(UploadDirectory) & Trim(uplImage.FileName)
FileExists = CheckForFile(FilePath)
'urk : Added validation for checking filename length and filesize being uploaded 06/01/2010.
If (e.IsValid) Then
If (e.UploadedFile.FileName.Length > 100) Then
e.ErrorText = "The file name cannot be more than 100 characters long. Please shorten and retry."
ElseIf (e.UploadedFile.FileName.Contains("'") Or e.UploadedFile.FileName.Contains("&")) Then
e.ErrorText = "The file name cannot contain the apostrophe or ampersand characters."
ElseIf (e.UploadedFile.FileName.EndsWith(".aspx")) Or (e.UploadedFile.FileName.EndsWith(".ASPX")) Then
e.ErrorText = ".aspx files are not allowed for upload."
ElseIf FileExists = True Then
e.ErrorText = "A file with this name has already been uploaded. Please rename and try again."
Else
e.CallbackData = SavePostedFile()
If e.CallbackData <> "" Then
s_UpdateAttachData()
End If
e.CallbackData = "File: '" + e.UploadedFile.FileName + "' uploaded successfully."
End If
End If
End Sub
Private Sub s_UpdateAttachData()
Dim i_date As DateTime = Now.Date
Dim DAL As New DataAccessLayer
ClientKey = Session("ClientKey")
Dim pPrintBy As Integer = Session("UserPKey")
Dim PrintDate As DateTime = Now
Dim s As Boolean
Dim FullAttchPath As String
If Len(trim(ClientKey)) = 1 Then
FullAttchPath = "DATA/AR00000" + ClientKey.ToString + "/AttachFiles/Case" + SelKey.ToString + "/" + Trim(uplImage.FileName)
ElseIf Len(Trim(ClientKey)) = 4 then
FullAttchPath = "DATA/AR00" + ClientKey.ToString + "/AttachFiles/Case" + SelKey.ToString + "/" + Trim(uplImage.FileName)
Else
FullAttchPath = "DATA/AR0" + ClientKey.ToString + "/AttachFiles/Case" + SelKey.ToString + "/" + Trim(uplImage.FileName)
End If
If Request.Form("chkPrivate") <> "" Then
s = 1
Else
s = 0
End If
DAL.InsertCasesAttachPKey(ClientKey, SelKey, Trim(uplImage.FileName), Trim(uplImage.FileName), pPrintBy, PrintDate, s, FullAttchPath, Session("FolderKey"))
End Sub
Protected Function CheckForFile(ByVal Filename As String) As Boolean
If File.Exists(Filename) Then
Return True
Else
Return False
End If
End Function
Protected Sub ddlFolders_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlFolders.SelectedIndexChanged
Session("FolderKey") = ddlFolders.SelectedValue
End Sub

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