Click here to Skip to main content
15,609,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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%" />


of course i have added
and also registered
on my webpage.
my code behind is as follow:

    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:
<add assembly="System.Core, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

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/");
        { 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
Updated 29-Mar-21 1:05am

1 solution

The type or namespace name 'Linq' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
That error suggests you've added using System.Data.Linq; rather than simply using System.Linq; - double-check your using statements.

The second code block you've shown will not give you any errors about the Linq query pattern. You'll need to provide the actual error details if you want someone to help you fix them.
Share this answer
Member 10235977 29-Mar-21 10:55am    
i have used System.Linq first. it gave the same errors as i have posted in my question.
Then i used System.Linq with System.Data.Linq. This also gave the same errors.
Richard Deeming 29-Mar-21 10:56am    
The namespace is System.Linq.

The error message in your question says you are trying to use System.Data.Linq, which doesn't exist.

Use the correct namespace.
Member 10235977 29-Mar-21 16:13pm    
thanks for your advice.
my using directives in both the cases are as follows:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using AjaxControlToolkit;
using System.Collections.Generic;
using AjaxControlToolkit;
using System.Linq;

in first block, i still get the error. in second block i do not get the error but slide show does not run. it appears the code dows not register images at all.

you may see the results at: for the first code block and for the second
thanks for help but i am looking foeward to more help to complete my proect.
Richard Deeming 30-Mar-21 3:25am    
The error message in your question is:
The type or namespace name 'Linq' does not exist in the namespace 'System.Data'

That means you have a using System.Data.Linq; statement somewhere.

If you don't have that statement, then that's not the error you're getting.
Member 10235977 30-Mar-21 13:24pm    
as i clarified earlier i am not getting any error after using System.Linq but i am not getting any images in slide show. I am not able to decipher what mistake i am making by which my images are not being detected by slideshow

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900