How to open files for read/write in .aspx 
Author Message
 How to open files for read/write in .aspx

First, I'm hearing two terms thrown around that I don't understand the difference between: ASP.NET and VB.NET.  Aren't active server pages written in VBScript, therefor .ASPX pages are written in VB.NET, right?

Also, where can I find a language reference.  I can't believe there are people all around me, programming in this language, and I can't find a simple reference book or website!  I don't want a book with lots of fat, I want something that's real straightforeward, like O'Reilley's "Javascript: the definitive guide" and "Dynamic HTML: the definitive reference".

Okay, now my real question: How do I open a file (as shown below in VBScript)?  The first error I get is...
Compiler Error Message: BC30188: Expected either a variable, constant, Enum, Type, or procedural declaration.

Source Error:

Line 8:  Dim ThisPage :     ' this document
Line 9:  '
Line 10: fsObject = Server.CreateObject("Scripting.FileSystemObject")
Line 11: ' --- parse path and file name ---
Line 12: x = InstrRev(Request.ServerVariables("PATH_TRANSLATED"),"\",-1,1)

Here's the relevant portion of a similar webpage (an active server page), where I enumerate the images in the current directory, and display them, as well as their path.  The page I'm now trying to write is similar, but would have a DELETE checkbox and an UPLOAD button and textbox (INPUT TYPE="file") for each image, which would be shown in a table (as it is here).  I need to use .ASPX, because .ASP doesn't (why I'll never understand) allow input type of file to be properly handled from a web form.  All I want to do is accept the file if it's the correct type, deposit it in the current directory, then reload the page, showing the new image added in.

' --- find images ---
Dim Img(100,2) : ' allow up to 100 image files
Dim Hmny : ' how many images we have in this directory
set folder = fsObject.GetFolder(ThisPath)
For Each imageFile in Folder.Files
  fileNam = fsObject.GetBaseName(imageFile)
  fileExt = UCase(fsObject.GetExtensionName(imageFile))
  Set fileAtr = fsObject.GetFile(imageFile)
  fileDat = fileAtr.DateLastModified
  fileSiz = fileAtr.Size
  ' -- we're only looking for image files (jpg, gif) --
  If fileExt = "JPG" or fileExt = "GIF" Then
    hmnyImages = hmnyImages + 1
    Img(hmnyImages,0) = fileNam & "." & fileExt
    Img(hmnyImages,1) = fileDat
    Img(hmnyImages,2) = Int(fileSiz / 1024) & " kb"
  End If
    <FORM NAME="f2">
    <TABLE border=1>
      <CAPTION ALIGN='center' STYLE="font-family:arial, sans-serif; font-size:10pt; font-weight:600">
y = 0 : ' cell counter so we go 5 across, then start on another <TR>
For x = 1 to hmnyImages

  If y = 4 then
    y = 0
    Response.Write "      </TR><TR>" & vbCrLf
  End If
  y = y + 1
  fileNam = WebPath & "/" & Img(x,0)
  Response.Write "        <TD ALIGN='center'>"
  Response.Write "<A HREF='" & fileNam & "' TARGET='_blank'>"
  Response.Write "<IMG SRC='" & fileNam & "' HEIGHT=80 WIDTH=100 BORDER=0></A><BR>"
  Response.Write "<INPUT NAME='IMAGE" & x & "' TYPE='text' SIZE='25' VALUE='" & fileNam & "'><BR>"
  Response.Write Img(x,1) & " - " & Img(x,2) & "</TD>" & vbCrLf
        <TD COLSPAN=4 ALIGN="center" VALIGN="bottom">

I've noticed other BS with (or or whatever you call it) such as the Response.Write must have parentheses around them, even though .asp is unconcerned with it.  Grrr... it just makes the pages less portable when going from .asp to .aspx.  Oh well.


Wed, 07 Apr 2004 11:54:32 GMT  
 How to open files for read/write in .aspx

ASP pages were normally written in VBScript, but could be written in any ActiveX scripting language. Microsoft supported VBScript and JScript (and ships interpreters for both with Windows); other vendors provided Perl, Python, and most other common scripting languages.

ASP.NET pages are written in some (but not all) .NET languages. Microsoft supports ASP.NET pages in VB.NET, C#, and JScript.NET with the .NET framework and Visual Studio.NET (though the IDE only supports C# and VB.NET; you have to write JScript.NET pages by hand); the separate J#.NET product provides support for ASP.NET pages in Java. ActiveState is providing support for ASP.NET pages written in Perl, and maybe in Python. Other third-party .NET language vendors may also be working on ASP.NET support.

VB.NET is intended to replace Visual Basic 6 in all cases and VBScript for building dynamic web pages.

  First, I'm hearing two terms thrown around that I don't understand the difference between: ASP.NET and VB.NET.  Aren't active server pages written in VBScript, therefor .ASPX pages are written in VB.NET, right?

Wed, 07 Apr 2004 00:30:02 GMT  
 [ 2 post ] 

 Relevant Pages 

1. open a binary file for reading/writing

2. open file for random LOCK READ WRITE as handle

3. Opening a File in Read&Write mode

4. file open, read and write

5. Open evry file, Read and Write with Api

6. Writing a VBS file which reads and writes to the registry

7. Open text file, read line, write to DB, read next line, write to Db and so on...HELP

8. why write in .aspx code??!!

9. How to open a file for read that is already open by another application

10. No Intellisense in WebForm1.aspx but works in WebForm1.aspx.vb

11. What is the relationship between an .aspx and an aspx.vb

12. Cant not communcate between aspx and aspx.vb


Powered by phpBB® Forum Software