The following code sample shows how to create a Slide Show Using WebServices
//////////////code behind..........
public partial class slideshow : System.Web.UI.Page { private static DataTable tblData = new DataTable(); photogalary.slideshow dd = new photogalary.slideshow();
protected void Page_Load(object sender, EventArgs e) { dd.pro_album_id = Convert.ToInt32(Session["album"]);
tblData = dd.slide(); if (this.IsPostBack) return;
// set the initial image if (tblData.Rows.Count > 0) {
for (int i = 0; i < tblData.Rows.Count; i++) {
imgShowImage.ImageUrl = tblData.Rows[i]["pic_path"].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(
dr["pic_path"].ToString(), dr["id"].ToString(), dr["pic_name"].ToString()); } return slides;
} } ........... ,,,,,,,,,,,,,,,,,,,,,,,,,, app class......... ............................... public class slideshow { static string conn = ConfigurationManager.ConnectionStrings["con"].ConnectionString.ToString(); SqlConnection con = new SqlConnection(conn);
protected int album_id; public int pro_album_id { get { return album_id; } set { album_id = value; } }
public DataTable slide () {
SqlDataAdapter adap = new SqlDataAdapter(); DataTable tblData1 = new DataTable(); if (con.State == ConnectionState.Open) { con.Close(); } con.Open(); SqlCommand cmd = new SqlCommand("selectpic_fromalbum", con); cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@album_id", SqlDbType.Int)); cmd.Parameters["@album_id"].Value = pro_album_id;
adap.SelectCommand = cmd; tblData1 = new DataTable(); adap.Fill(tblData1); return (tblData1); }
} .....................source. SlideShowServiceMethod="GetSlides" AutoPlay="true" ImageTitleLabelID="imageTitle" ImageDescriptionLabelID="imageLabel1" NextButtonID="nextButton" PlayButtonText="Play" StopButtonText="Stop" PreviousButtonID="prevButton" PlayButtonID="playButton" Loop="true">
|
| Author: sreelatha yalamanchi 16 Jun 2008 | Member Level: Silver Points : 1 |
thank you very much for the code.....it was really helpful to me...keep on posting..
|