labs.insert-title.com

ASP to ASP.NET IV

The imageBOX (Our Print Portfolio)


<%
dim iStart
dim iStop

   if request.querystring("iStart") = "" then
      iStart = 0
   else
      iStart = request.querystring("iStart")
   end if

iStop = iStart + 2

with response
.write "<h1>Chicago Business Cards</h1>"

Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("DIRECT PATH TO OUR PRINT IMAGES")
Set files = folder.Files

dim printARR()
   For Each file in Files
      redim preserve printARR(y)
      printARR(y) = file.name
      y = y + 1
   next


.write "<table border=""0"" width=""100%"">"
.write "<tr>"
.write "<td width=""25%"">"

   if iStart > 0 then
      response.write "<a href=""printport.asp"">First</a><br><br>"
   end if

.write "</td>"
.write "<td width=""25%"">"

   if iStart > 0 then
      response.write "<a href=""printport.asp?iStart=" & iStart - 3 & """>Previous</a><br><br>"
   end if

.write "</td>"
.write "<td width=""25%"">"

   if iStop < (ubound(printARR) * 1) then
      response.write "<a href=""printport.asp?iStart=" & iStop + 1 & """>Next</a><br><br>"
   end if

.write "</td>"
.write "<td width=""25%"">"

   if iStop < ubound(printARR) then
      response.write "<a href=""printport.asp?iStart=" & ubound(printARR) - 2 & """>Last</a><br><br>"
   end if

.write "</td>"
.write "</tr></table>"

   if ubound(printARR) < iStop then
      iStop = ubound(printARR)
   end if

   for i = iStart to iStop
      response.write "<img src=""printimages/" & printARR(i) & """><br /><br />"
   next

end with
Set files = folder.Files
Set file = Nothing
Set fso = Nothing

%>

So the issues at hand are how does ASP.NET handle Arrays and the File System Object of ASP Classic....

I sought out answers...

references so far:

After reading all this and some others I will list below, I have decided to use the ASP.NET datagrid instead of the Array I used in the original script. I did start off writing an ASP.NET script using the array which was more true to the original script, but never got a real grip on how to page through the DataList. The built in paging in the DataGrid is just awesome and too good to pass up.


<%@ Import Namespace="System.IO" %>

<script language="VB" runat="server">
  Sub Page_Load(sender as Object, e as EventArgs)
    BindData()
  End Sub


 Sub BindData()
    Dim dirInfo as New DirectoryInfo("PATH TO FILE")
    imageList.DataSource = dirInfo.GetFiles("*.jpg")
    imageList.DataBind()
  End Sub


 Sub NewPage (sender As Object, e As DataGridPageChangedEventArgs)
    imageList.CurrentPageIndex = e.NewPageIndex
    BindData()
  End Sub

</script>
<form runat="server">


<asp:DataGrid runat="server"
	id="imageList"
	AutoGenerateColumns="False"
	AllowPaging="True"
	OnPageIndexChanged="NewPage"
	PageSize = "3"
	showheader = "True"
	border="0"
	>
    <pagerstyle
         nextpagetext="Next" prevpagetext="Back"
         CssClass="a"
         position="top"
         pagebuttoncount=3
         horizontalalign="left" />

<Columns>
	<asp:TemplateColumn>
	<ItemTemplate>
	<asp:Image
	ImageUrl='<%# "printimages/" &  DataBinder.Eval(Container.DataItem, "Name") %>'
	runat="server"/>
	</ItemTemplate>
	</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</form>

While this solution works for us I still want to rebuild the very customizable imageBOX as well as further develop the look and feel of the datagrid. Need "First" and "Last" links and the ability to add different image types.

Although, in my reading I am finding it is not that hard to build the First Page and Last Page links, I am somewhat disappointed that this functionality isn't already built in to the datagrid. It would seem so natural in conjunction with the functionality that is already there... maybe this was a rushed job? Is there some reason this wasn't added in ?

As a side note I talked extensively with Dan Kirkwood Jr., of Eagle Innovations, Inc., about this topic, as he is as far as I know the only ASP.NET guru I personally know. Here's a a bit of that Conversation






Discussion

somr

moja stranka

New comments are currently disabled, you can find me @joemaddalone Comments temporarily disabled for now, you can find me @joemaddalone