Have you downloaded the Ajax toolkit from http://ajax.asp.net/ajaxtoolkit/ and do you have the example SlideShow control example working on your machine?
<form id=form1 runat="server"> <div>Hello again my friend,</div> <div> </div> <div>I have made the following page for you. My page gets a list of countries from my database and then uses their images as slides. The images are assumed to be held within the
"images" folder on the website and their urls in the database just consist of "France.jpg", "Italy.jpg" so the "images/" part is added on in the code.
</div> <div>Also, I use cc1 as the prefix for the AjaxToolkit controls and I declare this in my web.config file as follows (you do not need to do this if you prefer to use your own prefix and your slider control is already working): -</div> <div> </div> <div><pages>
<controls>
<add tagPrefix="cc1" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"/>
I modified it slightly to make it WHERE the propertyID (for mine) is equal to the QueryStringID. But for some reason the buttons disable after the first image. heres what i did i wonder if you can help :
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default4 : System.Web.UI.Page
{
string QueryStringID;
private static DataTable tblData = new DataTable();
string strSQL = "SELECT PhotoID, Caption, PhotoURL FROM LandlordPhotos WHERE PropertyID = @PropID";
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BlinkConnectionString"].ConnectionString);
conn.Open();
SqlCommand comm = new SqlCommand(strSQL, conn);
comm.Parameters.Add("@PropID", SqlDbType.VarChar).Value = QueryStringID;
SqlDataAdapter da = new SqlDataAdapter(comm);
tblData = new DataTable();
da.Fill(tblData);
conn.Close();
// set the initial image
if (tblData.Rows.Count > 0)
{
imgShowImage.ImageUrl = "PictureThis/Landlords/" + tblData.Rows[0]["PhotoURL"].ToString();
}
}
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static AjaxControlToolkit.Slide[] GetSlides()
{
AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[tblData.Rows.Count];
for (int i = 0; i < tblData.Rows.Count; i++)
{
DataRow dr = tblData.Rows[i];
slides[i] = new AjaxControlToolkit.Slide(
"PictureThis/Landlords/" + dr["PhotoURL"].ToString(),
dr["PhotoID"].ToString(),
dr["Caption"].ToString());
}
return slides;
}
}
I would make sure that the images are being returned from the database. Add <asp:DataGrid id="dgdTest" runat="server"/> to your web page and then after conn.Close() in the code, add: -
dgdTest.DataSource = tblData;
dgdTest.DataBind();
This will check that the rows are being returned. If you still have problems, I will need to see your aspx page.
Hey, ok ive sorted the WHERE statment, but my images have their height and width in the database as well, is there a way of assiging the width / height to the image feild as well? heres my new code :
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default4 : System.Web.UI.Page
{
string QueryStringID;
private static DataTable tblData = new DataTable();
vjaiprakash7...
Member
11 Points
5 Posts
Slideshow with Database
May 26, 2007 04:03 PM|LINK
Hi,
Please tell me how can i make slideshow with database.
please reply me urgently
SlideShow AjaxControl Toolkit
MCP, MCTS, MCT
ask_Scotty
Contributor
4146 Points
707 Posts
Re: Slideshow with Database
May 26, 2007 07:10 PM|LINK
Hello my friend,
Have you downloaded the Ajax toolkit from http://ajax.asp.net/ajaxtoolkit/ and do you have the example SlideShow control example working on your machine?
Kind regards
Scotty
mlopilato
Member
30 Points
12 Posts
Re: Slideshow with Database
May 26, 2007 10:06 PM|LINK
I'm trying to do that right now.
The toolkit example doesn't show db or filesystem use.
I need to pull the images from the filesystem if the exist and if not show a default image or no image.
blink18jew
Member
199 Points
648 Posts
Re: Slideshow with Database
May 26, 2007 11:31 PM|LINK
do you mean you want a slideshow with the slides generated by an SQL station from a database? Si!
ask_Scotty
Contributor
4146 Points
707 Posts
Re: Slideshow with Database
May 27, 2007 11:09 AM|LINK
</div> <div>Also, I use cc1 as the prefix for the AjaxToolkit controls and I declare this in my web.config file as follows (you do not need to do this if you prefer to use your own prefix and your slider control is already working): -</div> <div> </div> <div><pages>
<controls>
<add tagPrefix="cc1" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"/>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages></div> <div>
Anyway, the page and code is as follows: -</div> <div> </div> <div> </div> <div><%@ Page Language="C#" AutoEventWireup="true" CodeFile="SlideShowTest.aspx.cs" Inherits="SlideShowTest" %></div> <div> </div> <div><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></div> <div> </div> <div><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div style="text-align:center">
<asp:Image ID="imgShowImage" runat="server"
Height="300"
Style="border: 1px solid black;width:auto"
AlternateText="" />
<asp:Label runat="Server" ID="imageLabel1"/><br /><br />
<asp:Button runat="Server" ID="prevButton" Text="Prev" Font-Size="Larger" />
<asp:Button runat="Server" ID="playButton" Text="Play" Font-Size="Larger" />
<asp:Button runat="Server" ID="nextButton" Text="Next" Font-Size="Larger" />
<cc1:SlideShowExtender ID="slideshowextend1" runat="server"
TargetControlID="imgShowImage"
SlideShowServiceMethod="GetSlides"
AutoPlay="true"
ImageDescriptionLabelID="imageLabel1"
NextButtonID="nextButton"
PlayButtonText="Play"
StopButtonText="Stop"
PreviousButtonID="prevButton"
PlayButtonID="playButton"
Loop="true" />
</div>
</div>
</form>
</body>
</html></div> <div> </div> <div>using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;</div> <div>
public partial class SlideShowTest : System.Web.UI.Page
{
private static DataTable tblData = new DataTable();</div> <div> </div> <div> protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack)
return;</div> <div>
string strSQL = "SELECT CountryName, OverView, ImageUrl FROM tblCountry";
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HolidaysDB"].ConnectionString);
conn.Open();</div> <div> </div> <div> SqlCommand comm = new SqlCommand(strSQL, conn);
SqlDataAdapter da = new SqlDataAdapter(comm);
tblData = new DataTable();
da.Fill(tblData);
conn.Close();</div> <div> </div> <div> // set the initial image
if (tblData.Rows.Count > 0)
{
imgShowImage.ImageUrl = "images/" + tblData.Rows[0]["ImageUrl"].ToString();
}
}</div> <div>
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static AjaxControlToolkit.Slide[] GetSlides()
{
AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[tblData.Rows.Count];</div> <div> </div> <div> for (int i = 0; i < tblData.Rows.Count; i++)
{
DataRow dr = tblData.Rows[i];</div> <div> slides[i] = new AjaxControlToolkit.Slide(
"images/" + dr["ImageUrl"].ToString(),
dr["CountryName"].ToString(),
dr["Overview"].ToString());
}</div> <div> return slides;
}</div> <div>}</div> <div> </div> <div> </div> <div>Kind regards</div> <div> </div> <div>Scotty</div> <div> </div> <div> </div></form>
blink18jew
Member
199 Points
648 Posts
Re: Slideshow with Database
May 27, 2007 01:12 PM|LINK
Hey that code is immense thank you very much.
I modified it slightly to make it WHERE the propertyID (for mine) is equal to the QueryStringID. But for some reason the buttons disable after the first image. heres what i did i wonder if you can help :
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default4 : System.Web.UI.Page
{
string QueryStringID;
private static DataTable tblData = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
QueryStringID = Request.QueryString["id"];
if (this.IsPostBack)
return;
string strSQL = "SELECT PhotoID, Caption, PhotoURL FROM LandlordPhotos WHERE PropertyID = @PropID";
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BlinkConnectionString"].ConnectionString);
conn.Open();
SqlCommand comm = new SqlCommand(strSQL, conn);
comm.Parameters.Add("@PropID", SqlDbType.VarChar).Value = QueryStringID;
SqlDataAdapter da = new SqlDataAdapter(comm);
tblData = new DataTable();
da.Fill(tblData);
conn.Close();
// set the initial image
if (tblData.Rows.Count > 0)
{
imgShowImage.ImageUrl = "PictureThis/Landlords/" + tblData.Rows[0]["PhotoURL"].ToString();
}
}
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static AjaxControlToolkit.Slide[] GetSlides()
{
AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[tblData.Rows.Count];
for (int i = 0; i < tblData.Rows.Count; i++)
{
DataRow dr = tblData.Rows[i];
slides[i] = new AjaxControlToolkit.Slide(
"PictureThis/Landlords/" + dr["PhotoURL"].ToString(),
dr["PhotoID"].ToString(),
dr["Caption"].ToString());
}
return slides;
}
}
Thanks in advance.Si!
ask_Scotty
Contributor
4146 Points
707 Posts
Re: Slideshow with Database
May 27, 2007 04:48 PM|LINK
Hello my friend,
I would make sure that the images are being returned from the database. Add <asp:DataGrid id="dgdTest" runat="server"/> to your web page and then after conn.Close() in the code, add: -
dgdTest.DataSource = tblData;
dgdTest.DataBind();
This will check that the rows are being returned. If you still have problems, I will need to see your aspx page.
Kind regards
Scotty
mlopilato
Member
30 Points
12 Posts
Re: Slideshow with Database
May 27, 2007 05:24 PM|LINK
Thanks, That's a great start.
My problem is that I have a folder with image files named:
r12345.jpg
r12345_2.jpg
r12345_3.jpg etc...
the 'r12345' is the value of the 'listing_id' field in the db.
I need to view all images the start with 'r12345'.
Thanks for your help!
blink18jew
Member
199 Points
648 Posts
Re: Slideshow with Database
May 27, 2007 07:43 PM|LINK
Hey, ok ive sorted the WHERE statment, but my images have their height and width in the database as well, is there a way of assiging the width / height to the image feild as well? heres my new code :
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default4 : System.Web.UI.Page
{
string QueryStringID;
private static DataTable tblData = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
QueryStringID = Request.QueryString["id"];
if (this.IsPostBack)
return;
string strSQL = "SELECT PhotoID, Caption, PhotoURL, ImageWidth, ImageHeight FROM LandlordPhotos WHERE PropertyID = @PropID";
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BlinkConnectionString"].ConnectionString);
conn.Open();
SqlCommand comm = new SqlCommand(strSQL, conn);
comm.Parameters.Add("@PropID", SqlDbType.VarChar).Value = QueryStringID;
SqlDataAdapter da = new SqlDataAdapter(comm);
tblData = new DataTable();
da.Fill(tblData);
conn.Close();
// set the initial image
if (tblData.Rows.Count > 0)
{
imgShowImage.ImageUrl = "PictureThis/Landlords/" + tblData.Rows[0]["PhotoURL"].ToString();
imgShowImage.Width = tblData.Rows[0]["ImageWidth"].ToString();
imgShowImage.Height = tblData.Rows[0]["ImageHeight"].ToString();
}
}
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static AjaxControlToolkit.Slide[] GetSlides()
{
AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[tblData.Rows.Count];
for (int i = 0; i < tblData.Rows.Count; i++)
{
DataRow dr = tblData.Rows[i];
slides[i] = new AjaxControlToolkit.Slide(
"PictureThis/Landlords/" + dr["PhotoURL"].ToString(),
dr["PhotoID"].ToString(),
dr["Caption"].ToString());
}
return slides;
}
}
it errors at the new assigned height / width. and i cant work out why. thanks in advance.
vjaiprakash7...
Member
11 Points
5 Posts
Re: Slideshow with Database
May 28, 2007 01:08 PM|LINK
Thanks for quick reply.
Your code is working nicely.
Please tell me how can i able to do the slideshow like in http://blogs.zdnet.com/.
In this website onClick button image of author change but i need to display that all information through Slideshow.
But in ajaxcontroltoolkit:slideshow we can only pass three parameters.
But I need more data to display..
Please reply me.[:(]
SlideShow AjaxControl Toolkit
MCP, MCTS, MCT