Hi forum, I have a little problem with this issue, I tried everything I could if I use the classic and normal example displaying the images, declaring them in the codebehind.aspx.vb, the control works fine, even when I try to show images calling them from an entire folder. But when I try to call the images from a SQL DB the problem starts. I'm putting the last code I wrote, really I do not know if that is OK, because I prefer to do other things of the project.
Here is the code for that example and works fine (calling the images from an entire folder): This in order to prove that there is nothing wrong with the configuration or something.
<asp:ScriptManager id="ScriptManager1" runat="server"></asp:ScriptManager><asp:Panel ID="panes" runat="server" Width="200px" style="position:absolute; left:0px" ><asp:Image ID="img1" runat="server" Height="172px" Width="133px" ImageUrl="cupfondo.png" /><asp:SlideShowExtender ID="slideshowextend1" runat="server" TargetControlID="img1" SlideShowServiceMethod="GetSlides" AutoPlay="false" NextButtonID="btnNext" PreviousButtonID="btnPrev" Loop="true"></asp:SlideShowExtender> '\ The below code I put it into the code behind file default.aspx.vb \'<System.Web.Services.WebMethod(), System.Web.Script.Services.ScriptMethod()> _ Public Shared Function GetSlides() As AjaxControlToolkit.Slide() Dim store_folder As String = HttpContext.Current.Server.MapPath("~/slidep") Dim collected_files As String() = System.IO.Directory.GetFiles(store_folder) Dim i As Integer = 0 Dim br As Integer = collected_files.Length Dim slide As AjaxControlToolkit.Slide() = New AjaxControlToolkit.Slide(br - 1) {} For Each file As String In collected_files slide(i) = New AjaxControlToolkit.Slide("slidep/" & file.Substring(store_folder.Length + 1), file, i.ToString()) i += 1 Next Return slide End Function
-------------------------------------------
And next, the code that I try to use for the example with a SQL DB:
Imports System.Collections.Generic Imports System.Linq Imports System.Web Imports System.IO Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Configuration Imports System.Data.SqlClient Imports System.Data Partial Class CALLING Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim SiteID As String SiteID = Request.QueryString("QueryID") slideshowextend1.ContextKey = SiteID End Sub <System.Web.Services.WebMethod(), System.Web.Script.Services.ScriptMethod()> _ Public Shared Function GetSlides() As AjaxControlToolkit.Slide() Dim I As Integer = 0 Dim use As SqlConnection Dim com As SqlCommand use = New SqlConnection("Data Source=JOSE;Initial Catalog=cupon;Integrated Security=True") Dim queryy As String = "select img from cups WHERE ImageID = @SiteID" com = New SqlCommand(queryy) com.Connection = use Dim DA As New SqlDataAdapter(com) Dim DT As New Data.DataSet DA.Fill(DT) Dim MySlides(DT.Tables(0).Rows.Count) As AjaxControlToolkit.Slide For I = 0 To (DT.Tables(0).Rows.Count - 1) MySlides(I) = New AjaxControlToolkit.Slide(DT.Tables(0).Rows(I).Item(0), "", "") Next Return (MySlides) End Function
I have a Handler.ashx file that works fine with other applications, may be that help a little, I do not know, and is:
<%@ WebHandler Language="VB" Class="Handler" %> Imports System.Web Imports System.Configuration Imports System.Data.SqlClient Public Class Handler Implements IHttpHandler Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim imageid As String = context.Request.QueryString("ImID") Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("con").ConnectionString) connection.Open() Dim command As New SqlCommand("select img from cups where ImageID=" & imageid, connection) Dim dr As SqlDataReader = command.ExecuteReader() dr.Read() context.Response.BinaryWrite(DirectCast(dr(0), [Byte]())) connection.Close() context.Response.[End]() End Sub Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return False End Get End Property End Class
Please HELP!!!!
Thanks!!!