【问题标题】:Load all image in the contain folder to image slider将包含文件夹中的所有图像加载到图像滑块
【发布时间】:2019-08-01 13:24:51
【问题描述】:

所以我接手了其他人的工作,我需要帮助将所有图像加载到图像滑块中。所以我将所有图像放在一个文件夹中,我希望图像滑块一张一张地显示该文件夹中的所有图像。我可以让滑块只显示一个图像,当我调试代码时,问题是它总是获取文件夹中最后一个图像的名称。

在 Dim str_filename 上,我总是只获得最后一张图像的名称。感谢您的帮助。

Function Setup_Slider_photo(ByVal str_path As String, ByVal str_slider As String) As String
    Dim str_html As String = ""

    If str_path.StartsWith("file:") Then
        str_path = str_path.Remove(0, 5)
    End If
    str_path = str_path.Replace("/", "\")

    If impersonateValidUser("reportingserver", "carsem", "password") Then
        Dim file_all As ArrayList = folder_bll.show_file_list(str_path)

        Dim file_list As New ArrayList
        str_html += "<div class='camera_wrap' id='camera_wrap_1' style='height:450px;'>"
        If file_all.Count > 0 Then

            For index As Integer = 1 To 12
                file_list.Add(file_all(0).ToString.Trim)
                Dim str_file_name As String = file_list.Item(file_list.Count - 1).ToString.Trim.Substring(0, file_list.Item(file_list.Count - 1).ToString.Trim.Length - 4).Trim
                str_html += "<div data-src='" & str_path.Replace("\\carsem.com.my\filesvr\CSSFILE1\", "..\CSSFILE1\") & file_list.Item(file_list.Count - 1).ToString & "'>"
                str_html += "<div class='col-md-3 col-sm-3 col-xs-6'><a href='../Event/Event_Image.aspx?e=" & str_slider & "' target='_self' style='text-decoration: none; cursor:hand' class='btn btn-sm animated-button victoria-two'>Click To View More</a></div>"
                str_html += "</div>"
            Next



        End If
        str_html += "</div>"

        undoImpersonation()
    End If
    Return str_html
End Function

【问题讨论】:

    标签: asp.net vb.net html


    【解决方案1】:

    您应该在循环中使用index 代替file_list.Count - 1

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-09
      • 2012-06-24
      • 1970-01-01
      相关资源
      最近更新 更多