This is a migrated thread and some comments may be shown as answers.
RadConfirm Block Thread doesn't work with Firefox 3
4 Answers 127 Views
This is a migrated thread and some comments may be shown as answers.
bemara57
Top achievements
Rank 1
bemara57 asked on 19 Jun 2008, 07:40 PM
I have a snippet that support helped me with to get the RadConfirm window to hold and listen to the user's answer (ok or cancel). It works great, but when trying it in Firefox 3, it always returns false, even if I press ok. Does anyone see why it would do that? It probably has something to do with mozEvent, but don't know much about what that does.

 
        <script type="text/javascript"
            //MAKE SURE THAT THE FOLLOWING SCRIPT IS PLACED AFTER THE RADWINDOWMANAGER DECLARATION 
            //Replace old radconfirm with a changed version.    
            var oldConfirm = radconfirm;    
             //TELERIK 
             //window.radconfirm = function(text, mozEvent) 
             //We will change the radconfirm function so it takes all the original radconfirm attributes 
            window.radconfirm = function(text, mozEvent, oWidth, oHeight, callerObj, oTitle)    
            {    
                var ev = mozEvent ? mozEvent : window.event; //Moz support requires passing the event argument manually    
                //Cancel the event    
                ev.cancelBubble = true;    
                ev.returnValue = false;    
                if (ev.stopPropagation) ev.stopPropagation();    
                if (ev.preventDefault) ev.preventDefault();    
                    
                //Determine who is the caller    
                var callerObj = ev.srcElement ? ev.srcElement : ev.target;    
       
                //Call the original radconfirm and pass it all necessary parameters    
                if (callerObj)     
                {    
                    //Show the confirm, then when it is closing, if returned value was true, automatically call the caller's click method again.    
                    var callBackFn = function (arg)    
                    {               
                        if (arg)    
                        {               
                            callerObj["onclick"] = "";              
                            if (callerObj.click) callerObj.click(); //Works fine every time in IE, but does not work for links in Moz    
                            else if (callerObj.tagName == "A"//We assume it is a link button!    
                            {                                                           
                                try   
                                {    
                                    eval(callerObj.href)    
                                }    
                                catch(e){}    
                            }    
                        }    
                    }    
                    //TELERIK 
                    //oldConfirm(text, callBackFn, 300, 100, null, null);        
                    //We will need to modify the oldconfirm as well                 
                    oldConfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle);  
                }    
                return false;    
            }               
        </script> 

4 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 20 Jun 2008, 03:06 PM
Hello bemara57,

I tried to reproduce the problem, but it is working as expected on my end. Can you please check the attached code and the movie and let me know if I am missing something?



Regards,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
bemara57
Top achievements
Rank 1
answered on 23 Jun 2008, 10:00 PM
Thanks for the code and video. It help me narrow it down to an escape/unescape problem. Not sure if this was your update, Firefox's or MS Ajax, but all of my links with validators involved are generated with %20 as spaces in the WebForm_DoPostBackWithOptions section of the link.

In Firefox's source code, the links look like this:
<a onclick="return radconfirm('Are you sure?', event, 400, 200,'','Custom title');" id="linkDelete" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;linkDelete&quot;, &quot;&quot;, true, &quot;Delete&quot;, &quot;&quot;, false, true))">Delete Item Link</a>

But when I right-click on the link and "copy link", it copies the link location like this:
javascript:WebForm_DoPostBackWithOptions(new%20WebForm_PostBackOptions("linkDelete",%20"",%20true,%20"Delete",%20"",%20false,%20true))

Notice the %20 for the spaces. It doesn't do this with IE7. IE copies the shortcut like this:
javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("linkDelete", "", true, "Delete", "", false, true))

The original problem can be replicated by adding a validator to the page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test4.aspx.cs" Inherits="test_Test4" %> 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
 
<!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 id="Head1" runat="server"
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager> 
     
    <script type="text/javascript">  
            //MAKE SURE THAT THE FOLLOWING SCRIPT IS PLACED AFTER THE RADWINDOWMANAGER DECLARATION  
            //Replace old radconfirm with a changed version.     
            var oldConfirm = radconfirm;     
             //TELERIK  
             //window.radconfirm = function(text, mozEvent)  
             //We will change the radconfirm function so it takes all the original radconfirm attributes  
            window.radconfirm = function(text, mozEvent, oWidth, oHeight, callerObj, oTitle)     
            {     
                var ev = mozEvent ? mozEvent : window.event; //Moz support requires passing the event argument manually     
                //Cancel the event     
                ev.cancelBubble = true;     
                ev.returnValue = false;     
                if (ev.stopPropagation) ev.stopPropagation();     
                if (ev.preventDefault) ev.preventDefault();     
                     
                //Determine who is the caller     
                var callerObj = ev.srcElement ? ev.srcElement : ev.target;     
        
                //Call the original radconfirm and pass it all necessary parameters     
                if (callerObj)      
                {     
                    //Show the confirm, then when it is closing, if returned value was true, automatically call the caller's click method again.     
                    var callBackFn = function (arg)     
                    {                
                        if (arg)     
                        {                
                            callerObj["onclick"] = "";               
                            if (callerObj.click) callerObj.click(); //Works fine every time in IE, but does not work for links in Moz     
                            else if (callerObj.tagName == "A") //We assume it is a link button!     
                            {                                                            
                                try    
                                {     
                                    eval(callerObj.href) 
                                }     
                                catch(e){}     
                            }     
                        }     
                    }     
                    //TELERIK  
                    //oldConfirm(text, callBackFn, 300, 100, null, null);         
                    //We will need to modify the oldconfirm as well                  
                    oldConfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle);   
                }     
                return false;     
            } 
             
            function CustomValidation(sender, eventArgs)  
            { 
                eventArgs.IsValid = true
            }          
        </script> 
         
        <asp:LinkButton ID="linkDelete" runat="server"  
            Text="Delete Item Link" 
            ValidationGroup="Delete"  
            OnClick="btnDelete_Click" 
            OnClientClick="return radconfirm('Are you sure?', event, 400, 200,'','Custom title');" /> 
                    
        </> 
         
        <asp:Button ID="btnDelete" runat="server"  
            Text="Delete Item Button"  
            ValidationGroup="Delete"  
            OnClick="btnDelete_Click" 
            OnClientClick="return radconfirm('Are you sure?', event, 400, 200,'','Custom title');" /> 
  
        </>         
         
        <asp:Label ID="lbl1" runat="server"></asp:Label>                
                 
        <asp:CustomValidator ID="CustomValidator1" runat="server"  
            ValidationGroup="Delete"  
            ClientValidationFunction="CustomValidation" 
            ErrorMessage="Error!"  
            Display="Dynamic" />  
    </form> 
</body> 
</html> 
 
 


So the way I fixed it was changed line 48 "eval(callerObj.href)" to "eval(unescape(callerObj.href))" in the try block. Before this change, the catch error would say it's not the right syntax, obviously because of the %20 spaces.

The only difference I saw from your "About Firefox" than mine was that I'm using Windows NT 5.2, while you were using Windows NT 5.1. Everything else was identical. What worries me is that as small as this problem is, it can create a domino effect of problems. Any thoughts as to what I'm experiencing?
0
Georgi Tunev
Telerik team
answered on 24 Jun 2008, 02:21 PM
Hi bemara57,

Thank you for sharing your solution with us and the rest of the community. We examined it and we believe that you will not experience any problems with it.


Your points were updated. I will also update the Code Library article on this topic with your solution.



All the best,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rodrigo olivares
Top achievements
Rank 1
answered on 14 Oct 2009, 06:21 PM
thanks for the correcction, did help me.

And how about the form validation?,  You did find the way to validate the form before to display the radconfirm?




Asked by
bemara57
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
bemara57
Top achievements
Rank 1
Rodrigo olivares
Top achievements
Rank 1
Share this question
or