I want to create a slide show using AjjaxSlideShowExtender.
This is the first time i am trying this. i have studied some tutorials and tried but i am getting into problem every time.
my source code is as follows:
<div id="slideshow" runat="server" style="position:absolute; left:20%; width:60%; text-align:center;">
<br />
<asp:Label ID="TitleLabel" runat="server"></asp:Label>
<br />
<asp:Image ID="Image1" runat="server" Width="400px" Height="300px" />
<asp:SlideShowExtender ID="SlideShowExtender1" runat="server" AutoPlay="true" Loop="false" PreviousButtonID="PreviousImageButton" NextButtonID="NextImageButton" PlayButtonID="StartStopImageButton" TargetControlID="Image1" PlayInterval="3000" SlideShowAnimationType="SlideRight" ImageTitleLabelID="DescriptionLabel" ImageDescriptionLabelID="DescriptionLabel" PlayButtonText="PLAY" StopButtonText="STOP" SlideShowServiceMethod="imgslides"></asp:SlideShowExtender>
<br />
<asp:Label ID="DescriptionLabel" runat="server"></asp:Label>
<br />
<asp:ImageButton ID="PreviousImageButton" runat="server" ImageUrl="~/Assets/leftarrow.JPG" Width="10%" />
<asp:Button ID="StartStopImageButton" runat="server" />
<asp:ImageButton ID="NextImageButton" runat="server" ImageUrl="~/Assets/rightarrow.JPG" Width="10%" />
</div>
of course i have added
ToolkitScriptManage
and also registered
Assembly="AjaxControlToolkit"
on my webpage.
my code behind is as follow:
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public AjaxControlToolkit.Slide[] imgslides()
{
List<Slide> slides = new List<Slide>();
string myimagedir = HttpContext.Current.Server.MapPath("~/slides/");
DirectoryInfo dir = new DirectoryInfo("myimagedir");
var myslides = from displaying in dir.GetFiles() select new Slide
{
Name = displaying.Name,
ImagePath = "Slides/"+ displaying.Name,
};
return myslides.ToArray();
}
When i run this code, I get the error:
CS1935: Could not find an implementation of the query pattern for source type 'System.IO.FileInfo[]'. 'Select' not found. Are you missing a reference or a using directive for 'System.Linq'?
apparently it is provoking me to add using directive:
using System.Linq;
but when i add this, i get another error
The type or namespace name 'Linq' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
Thus a viciou circle is created to add this directive or not.
My server has ASP.NEY 4
I have also tried using assembly reference for .NET3.5 im my config pa:
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
but it gives the same result.
What I have tried:
i have also tried another code from a tutorial. for the same source code my code behind in this case is as follows:
public AjaxControlToolkit.Slide[] imgslides()
{
List<Slide> slide = new List<Slide>();
string path = HttpContext.Current.Server.MapPath("~/Slides/");
if(path.EndsWith("\\"))
{ path = path.Remove(path.Length - 1); }
Uri pathurl = new Uri(path, UriKind.Absolute);
string[] files = Directory.GetFiles(path);
foreach (string file in files)
{
System.Uri filepaturi = new Uri(file, UriKind.Absolute);
slide.Add(new Slide
{
Name = Path.GetFileNameWithoutExtension(file),
ImagePath = pathurl.MakeRelativeUri(filepaturi).ToString(),
});
}
return slide.ToArray();
}
This also gives same kind of errors as in my previous code.
I find AjaxSlideShowExtender is being extensively used on many sites. There must be some way out that i am not able to get.
Kindly help me with some code / tutorial that does not require to use Linq or some code / tutorial to get over the Linq problem so that i can use the above codes.
Many thanks for your help