Wednesday, March 21, 2012

AJAX SlideShow. Works in IE not FF

Hi,

I am very new to AJAX and upon some research I found a piece of code which does what I wanted but it was in C# so I converted it to VB.NET.

Anyways the code works just fine when I run the webpage in IE but doesn't work in FF and I can't figure out what is it that is going wrong? I was wondering if someone can help me out with it.

Also I was wondering if someone can help me add a checkbox on the form which allows me to turn the slideshow ON/OFF?

I wasn't able to upload a file here so here is the link to my projecthttp://www.patel.com.au/ausshare/slideshow.zip

Hope this makes sense.

Cheers :)

Nirav

First of all, I hope you realize that your project is using ASP.net callbacks and not ASP.net Ajax.

Regardless, the reason it is failing in Firefox is because you are returning filepaths instead of url paths. So a request for the image is made like so:

http://localhost:2032/SlideShow/images\testimage1.jpg . IE is forgivng but Firefox is not.

A quick fix would be to do this

return returnresult.Replace("\", "/")


Thanks Raj. I tried your way but no joy on FF.

Gee Whiz..this is an embarrassing moment. I really thought this was AJAX.

In your openion which one is a better method? AJAX or Callbacks? Also if AJAX is better than can it be implemented on production site since I heard it was in beta.

Would it be possible for you to help me out with converting this to AJAX or even a normal ASP.NET with Javascript slideshow with a checkbox which allows me to turn the slideshow On/Off?

Cheers,

Nirav


Which version u r using now?

Use AJAX RC1 it support for FF also...

Smile


Thanks Chetan.

I am using ASP.NET 2.0 and VB.NET as a language.

I am not allowed to install anynew stuff than a standard build since the website hosting has very strict requirements of using only thing out of the box which MS provided with .NET 2.0 Framework.

Thanks :)


It works in Firefox. I have tested it. Here is the code you have to change:

Public Function GetNextImageUrl() As String
'Return the next image to be displayed
Dim returnresult As String = String.Empty

Dim lastimagepath As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "images", m_lastFileName)

If files.Length > 0 Then
Dim index As Integer = Array.IndexOf(files, lastimagepath)

'Making sure that we don't get an index out of bound error when we reach the last photo
If index = files.Length - 1 Then
'If we are at the last image then start over
returnresult = files(0).Replace(AppDomain.CurrentDomain.BaseDirectory, String.Empty)
Else
'If we are not at the last image then continue returning the next one in line
returnresult = files(index + 1).Replace(AppDomain.CurrentDomain.BaseDirectory, String.Empty)
End If
End If

Return returnresult.Replace("\", "/")
End Function

Both callbacks and ASP.net are supported in both browsers. ASP.net Ajax is in RC (release candidate) and will be released soon.


Thanks Ra

Thanks Raj,

That is exactly what I did and it didn't work. I think somehow it wasn't compiled correctly as the breakpoint told me the source is changed and different and the breakpoint was disabled.

Is there a way to clear it?

Cheers :)


Please try recompiling your project then - and remove all breakpoints. Regards.

It's working now thanks a lot Raj.

Now I was wondering if you can help me add a checkbox and which will allow me to Start/Stop the slideshow?

Cheers :)

No comments:

Post a Comment