|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
I am trying to convert an asp listing script into an asp.net page. I already eliminated the SET and LET keys but i get this error.
Code:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30451: Name 'objCollection' is not declared. Source Error: Line 99: ' output the folder list Line 100:'''''''''''''''''''''''''''''''''''''''' Line 101:objCollection = objFolder.SubFolders Line 102:For Each objItem in objCollection Line 103:strName = objItem.Name on Any Help? Thanks. |
|
#2
|
||||
|
||||
|
Did you declare objCollection? The error is pretty obvious.
__________________
jmurrayhead Did I help you out? Make me popular by clicking the icon!New Members:Proper way to post a question Powered by ASP.Net |
|
#3
|
|||
|
|||
|
So i messed with it and fixed the dim problem (i had declared objcollection, no idea why that hadn't worked) now its giving me this error... weird stuff
Quote:
Entire Source Code: Sorry Its so Long... Code:
<%@ Page Language="VB" MasterPageFile="/districtart/master/MasterPage.master" AutoEventWireup="false" title="CRCSD Test Page" %>
<asp:Content ID="content3" ContentPlaceHolderID="prehead" Runat="Server">
<%
On Error Resume Next
' declare variables
Dim objFSO, objFolder
Dim objCollection, objItem
Dim strPhysicalPath, strTitle, strServerName
Dim strPath, strTemp, foldName, foldTemp
Dim strName, strFile, strExt, strAttr, strDisplay
Dim intSizeB, intSizeK, intAttr, dtmDate
' get the current folder URL path
strTemp = Mid(Request.ServerVariables("URL"),2)
strPath = ""
Do While Instr(strTemp,"/")
foldTemp = Left(strTemp,Instr(strTemp,"/"))
strPath = strPath & Left(strTemp,Instr(strTemp,"/"))
strTemp = Mid(strTemp,Instr(strTemp,"/")+1)
Loop
foldName = Right(foldTemp,Instr(foldTemp,"/"))
foldName = Left(foldName,Len(foldName)-1)
strPath = "/" & strPath
' build the page title
strServerName = UCase(Request.ServerVariables("SERVER_NAME"))
strTitle = "Contents of the " & foldName & " folder"
' create the file system objects
strPhysicalPath = Server.MapPath(strPath)
objFSO = Server.CreateObject("Scripting.FileSystemObject")
objFolder = objFSO.GetFolder(strPhysicalPath)
%>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style18
{
width: 100%;
}
.style19
{
width: 396px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CurrentGallery" runat="server">
<table border="0" width="775" cellspacing="0" cellpadding="0">
<tr>
<td width="706" valign="top" style="border-style: solid; border-color:#000000; border-width: 1">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><!--#include virtual="/gallery/artgallery/menu.asp"-->
<br> Albums are organized by school year.
</td>
</tr>
<tr>
<td align="center">
<script>
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,men ubar=0,resizable=0,width=780,height=550,left = 0,top = 0');");
}
// End -->
</script><div align="left">
<table border="0" cellspacing="0" width="600">
<tr>
<td width="526">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top" align="left">
<div align="center"><br>
<table width="200" border="0" cellspacing="0" cellpadding="5">
<%
''''''''''''''''''''''''''''''''''''''''
' output the folder list
''''''''''''''''''''''''''''''''''''''''
'Dim objcollection As objFolder.Subfolders
Dim objCollection = New objFolder.SubFolders
For Each objItem in objCollection
strName = objItem.Name
strAttr = MakeAttr(objItem.Attributes)
dtmDate = CDate(objItem.DateLastModified)
%>
<% If (Left(strName,1) <> "_") AND (strName <> "Default") then %>
<tr>
<td align="left">
<a href="javascript:popUp('<%=strName%>/index.htm')" class="black"><%=strName%></a></td>
</tr>
<% end if%>
<% Next %>
<tr>
<td width="275">
</td>
</tr>
</table> </div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td></tr>
</table>
</td>
</tr>
</table>
</asp:Content>
This worked with a regular asp page... am i going to have to go back to that? I'd rather not as my master page uses alot of asp.net stuff that i don't want to recreate in asp before my deadline on this project. |
|
#4
|
||||
|
||||
|
It looks like you're trying to list files and folders on the server. Have a look at this snippet: http://aspnet101.com/aspnet101/tutorials.aspx?id=12
Keep in mind the major differences between classic ASP and ASP.Net. It's not always easy to convert and there is usually a better way to handle things in ASP.Net than there is in classic ASP. |
|
#5
|
||||
|
||||
|
you have long way ahead of you, canarchy.. judging from your current
code you don't have the required .NET skills - yet. I would advice you to spend as much time as you need in learning the basics of .NET and the syntax of VB.NET and only then get back to your code. |
|
#6
|
|||
|
|||
|
Thanks for the help so far, i added the line
Code:
<%@ Import Namespace="System.IO" %> |
|
#7
|
||||
|
||||
|
Are you saying this code came from a Tutorial? If so, abandon that tutorial now!. It looks like you are trying to code ASP.NET while your classic ASP glasses are still on. It is quite unusual to plop code in the middle of a page like this is ASP.NET.
__________________
Wolffy ------------------------ Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary. Not FDIC insured |
|
#8
|
|||
|
|||
|
So I fixed it by going to regular asp and using the following code.
Before the HTML tag: Code:
<%
Option Explicit
On Error Resume Next
' declare variables
Dim objFSO, objFolder
Dim objCollection, objItem
Dim strPhysicalPath, strTitle, strServerName
Dim strPath, strTemp, foldName, foldTemp
Dim strName, strFile, strExt, strAttr, strDisplay
Dim intSizeB, intSizeK, intAttr, dtmDate
' don't cache the page
Response.AddHeader "Pragma", "No-Cache"
Response.CacheControl = "Private"
' get the current folder URL path
strTemp = Mid(Request.ServerVariables("URL"),2)
strPath = ""
Do While Instr(strTemp,"/")
foldTemp = Left(strTemp,Instr(strTemp,"/"))
strPath = strPath & Left(strTemp,Instr(strTemp,"/"))
strTemp = Mid(strTemp,Instr(strTemp,"/")+1)
Loop
foldName = Right(foldTemp,Instr(foldTemp,"/"))
foldName = Left(foldName,Len(foldName)-1)
strPath = "/" & strPath
' build the page title
strServerName = UCase(Request.ServerVariables("SERVER_NAME"))
strTitle = "Contents of the " & foldName & " folder"
' create the file system objects
strPhysicalPath = Server.MapPath(strPath)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPhysicalPath)
%>
In the body. Code:
<!-- Heres hte crap -->
<table border="0" cellspacing="0" cellpadding="0" align="center">
<td valign="top" style="border-style: solid; border-color:#000000; border-width: 1">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><!--#include virtual="/gallery/artgallery/menu.asp"-->
<br> Albums are organized by school year.
</td>
</tr>
<tr>
<td align="center">
<script>
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,men ubar=0,resizable=0,width=780,height=550,left = 0,top = 0');");
}</style>
// End -->
</script><div align="left">
<table border="0" cellspacing="0">
<tr>
<td width="526">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top" align="left">
<div align="center"><br>
<table width="200" border="0" cellspacing="0" cellpadding="5">
<%
''''''''''''''''''''''''''''''''''''''''
' output the folder list
''''''''''''''''''''''''''''''''''''''''
Set objCollection = objFolder.SubFolders
For Each objItem in objCollection
strName = objItem.Name
strAttr = MakeAttr(objItem.Attributes)
dtmDate = CDate(objItem.DateLastModified)
%>
<% If (Left(strName,1) <> "_") AND (strName <> "Default") then %>
<tr>
<td align="left">
<a href="javascript:popUp('<%=strName%>/index.htm')" class="black"><%=strName%></a></td>
</tr>
<% end if%>
<% Next %>
<tr>
<td width="275">
</td>
</tr>
</table> </div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td></tr>
</table>
</td>
</tr>
</table>
</td>
</tr></table>
|
|
#9
|
||||
|
||||
|
I wouldn't consider that "fixing" it. Sure, it does what you want it to, but you had to resort to Classic ASP in an ASP.Net environment.
|
|
#10
|
|||
|
|||
|
I am still trying to make the .net page work, but as long as that is not working i am going to use this page. My main question it seems is: how do i define a type?
The error seems strait forward enough... |
|
#11
|
||||
|
||||
|
This error means that the compiler does not recognise 'objFolder.SubFolders'. Either it does not exist or the proper namespace hasn't been imported. There are several examples online on how to do this the .Net way, however, I would take the suggestion given regarding learning the basics.
|
|
#12
|
|
|
|