Click to See Complete Forum and Search --> : Link or forms?
Hi!
I'm writing som ASP-code that stores information i TXT-files. I want to view the content of the TXT-file in another frame.
My question is if it's possible to open the files without using Select tags and submit buttons and instead use links? I guess it will be problem without request.querystring("") to know what I klicked on?
Or is it possible to solve in another way?
Looking forward to get som help!
Thanks
russell
01-01-2007, 02:09 PM
all u need is regular html tags:
<a href="yourTextFile.txt" target="frameName">
Click to see text file
</a>
all u need is regular html tags:
<a href="yourTextFile.txt" target="frameName">
Click to see text file
</a>
Thanks for your answer! But it's not that simple! I want to open a ASP-file in another frame by clicking on a simpe <A href> tag link. And when that ASP-file runs it must get information about specials TXT-files like ASP Request.Quearystring() like from a dropdown menu with select tags that has values that could be requested with Request.Quearystring() ?? Do you understand my problem?
I don't want to open the TXT files and view them, I just want to open them with a ASP-file and get some information that the ASP file then will show in the frame. And how will the ASP-file know which option that has been made in the other frame? I'm almost certain it's impossible, but I want to try and know! :confused:
Thanks
russell
01-01-2007, 07:51 PM
definitely possible. use Scripting.FileSystemObject (http://msdn.microsoft.com/library/en-us/script56/html/8b99eead-e2bd-45c6-9660-bbbfeec192f0.asp?frame=true) to read file.
can pass parameter as to which file in the querystring. u can use href tags with target=framename and then parse the querystring in the frame. if u want a select element to do it, need to use a little javascript too.
Univac
01-01-2007, 10:52 PM
In the interest of the Analema, What is your longitude? Thanks (Where are you)
definitely possible. use Scripting.FileSystemObject (http://msdn.microsoft.com/library/en-us/script56/html/8b99eead-e2bd-45c6-9660-bbbfeec192f0.asp?frame=true) to read file.
can pass parameter as to which file in the querystring. u can use href tags with target=framename and then parse the querystring in the frame. if u want a select element to do it, need to use a little javascript too.
Do you have some example or link where i can find it?
russell
01-02-2007, 10:25 AM
ok, here's a simple example. i gave u a link already to the Scripting.FileSystemObject documentation.
suppose you have 3 text files named TextFile1.txt, textFile2.txt, etc..
Here is the main html page. i used an iframe, but u could use a frameset as well.
<ul>
<li><a href="processFile.asp?f=1" target=frame2>Text File 1</a></li>
<li><a href="processFile.asp?f=2" target=frame2>Text File 2</a></li>
<li><a href="processFile.asp?f=3" target=frame2>Text File 3</a></li>
</ul>
<iframe name=frame2></iframe>
now u are passing a querystring param, which we'll check in the target frame and load the appropriate file. So the code in processFile.asp might look like this
<%
Dim fl
Dim fileToRead
fl = Request.QueryString("fl")
If Len(fl) Then
fileToRead = "TextFile" & fl & ".txt"
ReadFile fileToRead
End If
Sub ReadFile(f)
Dim fso
Dim tst
Dim strFileContents
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set tst = fso.OpenTextFile(f, 1, false)
strFileContents = tst.readAll
tst.close
Set tst = Nothing
Set fso = Nothing
End Sub
%>
all this does is loads the contents of the file into a variable -- strFileContents. you will have to parse out whatever specific information you are looking for in the file. FSO also allows u to view/modify metadata -- things like attributes, modified date, etc.
Thanks russel!
Now we are on the right track! I think the example in red below is what I'm looking for! I know almost all about scripting file objects, and I looked at the pages in the link you gave me. But this is what I was looking for and how to "grab" in the ASP processing file.
I guess there is no problem to put this code into a ASP file and put som VBscript code in between the lines like ....<a href="processFile.asp?<=%value%>" Target.....
<li><a href="processFile.asp?f=1" target=frame2>Text File 1</a></li>
I'm going to test this later this week. Thanks! :)