Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

slide show

Posted on 2011-10-10
10
Medium Priority
?
337 Views
Last Modified: 2012-05-12
Hey guys i have this transaction in c# but in google chrome it does not work?

please help

 private string GetNextTransition()
    {
        int n = (int)((new Random().NextDouble()) * 5);
        switch (n)
        {
            case 0:
            case 1:
                n = (int)((new Random().NextDouble()) * 22);
                return "revealTrans(duration=2,transition=" + n.ToString() + ")";
            case 2:
            case 3:
                if (Request.Browser.Browser == "IE")
                {
                    n = (int)((new Random().NextDouble()) * 8);
                    switch (n)
                    {
                        case 0:
                            return "progid:DXImageTransform.Microsoft.RandomDissolve()";
                        case 1:
                            return "progid:DXImageTransform.Microsoft.Pixelate(MaxSquare=20, Duration=2, Enabled=false)";
                        case 2:
                            return "progid:DXImageTransform.Microsoft.RadialWipe(wipeStyle='clock')";
                        case 3:
                            return "progid:DXImageTransform.Microsoft.Wheel(spokes=4)";
                        case 4:
                            return "progid:DXImageTransform.Microsoft.Stretch(stretchStyle='spin')";
                        default:
                            return "progid:DXImageTransform.Microsoft.Stretch(stretchStyle='push')";
                    }
                }
                else
                    return "blendTrans(duration=2)";
            default:
                return "blendTrans(duration=2)";
        }
    }
0
Comment
Question by:JCWEBHOST
  • 6
  • 4
10 Comments
 
LVL 9

Expert Comment

by:Roman Gherman
ID: 36941370
you have a check for Internet explorer - it will do a different thing than for other browsers:
 -  if (Request.Browser.Browser == "IE")


But for other browsers it is doing something different.
     return "blendTrans(duration=2)";

well it is hard to say what is not working without knowing the problem and code.

it could be that that way it should work for browsers different than Internet explorer
0
 

Author Comment

by:JCWEBHOST
ID: 36941378
yes it works in IE but does noting in Google chrome
0
 

Author Comment

by:JCWEBHOST
ID: 36941381
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class _Default : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
{
    string m_lastFileName = "none";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
            return;

        photo.Src = GetNextImageUrl();

        //Register Ajax client script to client's browsers.  This has to be hard coded.
        string cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");
        string callbackScript = "function CallServer(arg, context)" + "{ " + cbReference + "} ;";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true);
    }

    public void RaiseCallbackEvent(string eventArgument)
    {
        //This is first place to receive the callback from client's browser.  The parameter 'eventArgument'
        //is the parameter passed from the Javascript's call 'CallServer()'.  In this example, it is the
        //last image url.
        m_lastFileName = Path.GetFileName(eventArgument);
    }

    public string GetCallbackResult()
    {
        //This is the second call triggled by the 'CallServer()' and it is the place to prepare and return a string
        //to the client.  Here the returned string is the image url and the transition effect.
        return GetNextImageUrl() + ";" + GetNextTransition();
    }

    private string GetNextImageUrl()
    {
        //Randomly pick a image file in the server.
        string[] files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "images", "*.jpg");
        if (files.Length == 0)
            return string.Empty;

        while (true)
        {
            int n = (int)((files.Length - 1) * (new Random()).NextDouble());
            //Do not want to repeat the last image
            if (files[n].IndexOf(m_lastFileName) < 0)
            {
                return files[n].Replace(AppDomain.CurrentDomain.BaseDirectory, string.Empty);
            }
        }
    }
    private string GetNextTransition()
    {
        //Randomly pick a transition effect.  Note some of the effects only work in IE.
        int n = (int)((new Random().NextDouble()) * 5);
        switch (n)
        {
            case 0:
            case 1:
                n = (int)((new Random().NextDouble()) * 22);
                return "revealTrans(duration=2,transition=" + n.ToString() + ")";
            case 2:
            case 3:
                if (Request.Browser.Browser == "IE")
                {
                    n = (int)((new Random().NextDouble()) * 8);
                    switch (n)
                    {
                        case 0:
                            return "progid:DXImageTransform.Microsoft.RandomDissolve()";
                        case 1:
                            return "progid:DXImageTransform.Microsoft.Pixelate(MaxSquare=20, Duration=2, Enabled=false)";
                        case 2:
                            return "progid:DXImageTransform.Microsoft.RadialWipe(wipeStyle='clock')";
                        case 3:
                            return "progid:DXImageTransform.Microsoft.Wheel(spokes=4)";
                        case 4:
                            return "progid:DXImageTransform.Microsoft.Stretch(stretchStyle='spin')";
                        default:
                            return "progid:DXImageTransform.Microsoft.Stretch(stretchStyle='push')";
                    }
                }
                else
                    return "blendTrans(duration=2)";
            default:
                return "blendTrans(duration=2)";
        }
    }
}

Open in new window


 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table>
        <tr>
            <td align="center">ASP.NET2 Slide Show<hr />
            </td>
        </tr>
        <tr>
            <td align="center">
                <img id="photo" src="" runat="server" border="0"/>
            </td>
        </tr>
    </table>
    </div>
    </form>

    <script type="text/javascript">
        //A timer will be fired in 5 seconds to call getNextImage()
        var c_interval = 5000;
        window.setTimeout("getNextImage()", c_interval);
        
        function getNextImage()
        {
            //Send the request to server with the current image url as the argument
            CallServer(document.getElementById("photo").src, "");
        }
                  
        function ReceiveServerData(rValue)
        {
            //Receive server's response of a string rValue, which is prepared in the server's function
            //GetCallbackResult()
            var wds = rValue.split(";");
            //Assign the transition effect
            document.getElementById("photo").style.filter = wds[1];
            //Preload the image file from server.  When finishing download, imageLoaded function will be called
            //with the img object as the argument                           
            var img  = new Image();
            img.onload = function(){ imageLoaded(this); }
            img.onerror = function(){ imageError(this); }
            img.onabort = function(){ imageError(this); }
            img.src = wds[0];                                            
        }
        function imageError(img)
        {
            //If image download errors occur, this function will be called.
            window.setTimeout("getNextImage()", 1000);
        }
        function imageLoaded(img)
        {
            var photo = document.getElementById("photo");   //Find the image control object
            photo.filters[0].apply();                       //Apply the transition effect
            photo.filters[0].play();                        //Play the effect and display the new image
            photo.src = img.src;                            //Assign the image to the image control
            
            window.setTimeout("getNextImage()", c_interval);//Initiate the next request
        }
    </script>

</body>
</html>

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Expert Comment

by:Roman Gherman
ID: 36941416
do you have anywhere the Javascript function "blendTrans"  defined?

I cant see it anywere.
0
 

Author Comment

by:JCWEBHOST
ID: 36941478
nope
0
 

Author Comment

by:JCWEBHOST
ID: 36941484
0
 

Author Comment

by:JCWEBHOST
ID: 36941516
thats my project
0
 
LVL 9

Expert Comment

by:Roman Gherman
ID: 36941559
OK, that will not work on other browsers except IE.
This is because almost all that code is specific for IE, sorry, but you will have to chose another slideshow component.

Regards,
Roman
0
 

Author Comment

by:JCWEBHOST
ID: 36941644
ok can you help me find one that will work in IE and google?
0
 
LVL 9

Accepted Solution

by:
Roman Gherman earned 2000 total points
ID: 36941841
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Screencast - Getting to Know the Pipeline
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question