#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    4
    Rep Power
    0

    SlideShowExtender doesn't work when I'm using Routes and a Handler


    Hi there. I have a problem with the SlideShowExtender.
    I wanted to load images from a database, using a handler. It works fine when I open the original page, without a Route. The Route also works for all page contents, but not the Slide Show Extender. I tried it, when the handler and the aspx-file were inside the root and when they were both inside the same subfolder. I tried it using hard coded and soft coded picture URLs and also the '../subfolder/myhandler.ashx'.
    Could you please have a look at the code and hopefully have a nice idea?

    Route:


    routes.MapPageRoute("myPictureshow", "myPictureshow-{uniformsqlid}", "~/myfolder/myPictureshow.aspx");

    script:
    [System.Web.Services.WebMethod]
    [System.Web.Script.Services.ScriptMethod]
    public static AjaxControlToolkit.Slide[] GetSlides()
    {
    List<AjaxControlToolkit.Slide> NewSlide = new List<Slide>();
    if (PictureContent != null)
    for (int PictureNumber = 0; PictureNumber < 8; PictureNumber++)
    if (PictureContent[PictureNumber]!=null)
    if (PictureContent[PictureNumber].Length > 0)
    {
    string PictureUrl = "myHandler.ashx?imgid=" + PictureNumber;
    // alternative: "../myfolder/myHandler.ashx?imgid=" + PictureNumber;
    //or: "localhost:12345/myfolder/myHandler.ashx?imgid=" + PictureNumber;
    NewSlide.Add(new AjaxControlToolkit.Slide(PictureUrl, "Bild 1", ""));
    };
    AjaxControlToolkit.Slide[] returnSlide = new Slide[NewSlide.Count];
    for (int PictureNumber = 0; PictureNumber < NewSlide.Count; PictureNumber++)
    returnSlide[PictureNumber] = NewSlide[PictureNumber];
    return returnSlide;
    }

    Handler:

    public void ProcessRequest(HttpContext context)
    {
    EinstellKlasse NeueKlasseEinstellen = new EinstellKlasse();
    if (context.Request.QueryString["imgid"] != null)
    {
    string id = context.Request.QueryString["imgid"].ToString();
    context.Response.ContentType = "image/jpeg";
    int PictureNumber = Convert.ToInt16(id);

    Stream stream = new MemoryStream((byte[])myPictureshow.PictureContent[PictureNumber]);

    byte[] buffer = new byte[2024];
    int byteSeq = stream.Read(buffer, 0, 2024);

    while (byteSeq > 0)
    {
    context.Response.OutputStream.Write(buffer, 0, byteSeq);
    byteSeq = stream.Read(buffer, 0, 2024);
    }

    }

    }

    Thx robinscorner
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    4
    Rep Power
    0

    I found a solution


    If you need to pass a variable to the current page containing the slide show, which does not accept Routes, you could do the following:You do not use a Route, but call the page like this:

    "~/MyFolder/examplepage.aspx/whateveryouwanttopass"

    Now in the codebehind file, you will find the variables (whateveryouwanttopass) when you enter

    this.Page.Request.PathInfo

    Hope it helps you too! robinscorner
  4. #3
  5. No Profile Picture
    Stumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,409
    Rep Power
    4538
    Thanks for posting your solution.
    ======
    Doug G
    ======
    It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    Hi there!


    Robin, could you please send me a zip file with the files that you use in this example? Or where can I download?

    Because, I have an example of code but it does not work. I can not make it work. Thanks!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    4
    Rep Power
    0
    Sorry, but I had some more probs like I couln't view several galleries on one page, so I changed everything. I'm using
    simplegallery now (Simple Controls Gallery v1.4, I am not allowed to send the link).

    Please, if you want to reconstruct my former method, search for generic handlers and images on google, do what ajax toolkit provides in the sample pages and put it together with the stuff I wrote above.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0
    Thanks! I visited the website of the control, so I think, that you wrote code for the image array to use a SQL DB with java, my problem is the same... I do not do familiar with java.

    However, glad to know how to do an array with java and make it work.




    Originally Posted by robinscorner
    Sorry, but I had some more probs like I couln't view several galleries on one page, so I changed everything. I'm using
    simplegallery now (Simple Controls Gallery v1.4, I am not allowed to send the link).

    Please, if you want to reconstruct my former method, search for generic handlers and images on google, do what ajax toolkit provides in the sample pages and put it together with the stuff I wrote above.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    4
    Rep Power
    0
    If you have your difficulties, please take a look at this helpful instruction of how to use it with a XML file:

    -link is not allowed, but seach for

    JQuery Image Gallery with XML
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0
    Ok, this documentation is very useful.
    Hope all these hints help me to make that image slider works from a SQL db.

    Thanks again!


    Originally Posted by robinscorner
    If you have your difficulties, please take a look at this helpful instruction of how to use it with a XML file:

    -link is not allowed, but seach for

    JQuery Image Gallery with XML
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    4
    Rep Power
    0
    Originally Posted by robinscorner
    If you need to pass a variable to the current page containing the slide show, which does not accept Routes, you could do the following:You do not use a Route, but call the page like this:

    "~/MyFolder/examplepage.aspx/whateveryouwanttopass"

    Now in the codebehind file, you will find the variables (whateveryouwanttopass) when you enter

    this.Page.Request.PathInfo

    Hope it helps you too! robinscorner
    nice sharing thanks

IMN logo majestic logo threadwatch logo seochat tools logo