Я пытаюсь опубликовать sh изображений в Карусели. Но изображение не загружается. Любой, кто может помочь, будет высоко оценен. Ниже приведен код:
код файла carousel_test.aspx ниже. Здесь, через Rgallery, я пытаюсь отобразить изображения карусели.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="carousel_test.aspx.cs" Inherits="reader.carousel_test" %>
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="css/style.css">
<!--Carousel -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<!--Carousel -->
<body>
<form id="form1" runat="server" style="font-size: small">
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<asp:Repeater ID="Rgallary" runat="server">
<ItemTemplate>
<div class="item" >
<div class="item active">
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "ImageHandler.ashx?ImID="+ Eval("product_sell_code") %>' />
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
//This is used for manual navigation like for next or previous
<a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
</div>
</form>
</body>
<script type="text/javascript">
$(document).ready(function () {
$('.carousel').carousel({
interval: 2500
})
});
</script>
код файла carousel_test.aspx.cs ниже. Это файл кода, куда я звоню для загрузки изображения из базы данных.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
namespace reader
{
public partial class carousel_test : System.Web.UI.Page
{
string sq = ConfigurationManager.ConnectionStrings["readerConnStr"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindslide();
}
}
public void bindslide()
{
SqlConnection connection = new SqlConnection(sq);
using (SqlCommand cmd = new SqlCommand("select product_sell_code from product_for_sell ", connection))
{
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
Rgallary.DataSource = ds;
}
Rgallary.DataBind();
connection.Dispose();
connection.Close();
}
}
}
ImageHandler.ashx.cs - это файл обработчика изображения
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace reader
{
/// <summary>
/// Summary description for $codebehindclassname$
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class ImageHandler : IHttpHandler
{
SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["readerConnStr"].ToString());
/* string strcon = ConfigurationManager.AppSettings["readerConnStr"].ToString(); */
public void ProcessRequest(HttpContext context)
{
string imageid = context.Request.QueryString["ImID"];
/* SqlConnection connection = new SqlConnection(strcon);*/
connection.Open();
SqlCommand command = new SqlCommand("select product_image from product_for_sell where product_sell_code=" + imageid, connection);
SqlDataReader dr = command.ExecuteReader();
dr.Read();
context.Response.BinaryWrite((Byte[])dr[0]);
connection.Close();
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
Вот код , Пожалуйста, помогите