Hello,
I spent hours trying to find what is the good sample to use when you want to add a confirm script to button or anchors using RadWindow.
On buttons I use:
string js = string.Format("return radconfirm('{0}', event, null, null,null,'{1}');", msg, title);
if ( Btn.Attributes["onclick"] != null)
Btn.Attributes["onclick"] = js;
else Btn.Attributes.Add("onclick",js);
I found a sample on forums which seems to be related to previous RadControls, not for AJX.NET and I got problems when the button is using call back.
This sample is based on following script.
I don't need this script on each page and I use a registerConfirm method in codebehind to insert it.
But this script should be called after RadWindowManager declaration, so I use following code to add it on the last instructions of the page:
string scrpt = "ConfirmLoadHandler();";
AjaxManager.ResponseScripts.Add(scrpt);
And I get problems on callback: I am fearing the radconfirm function is replaced many times ? How to control this.
Is there a more recent sample we could use with last 2.1001 version to have a safely confirm with radWindows.
Thanks for clarification.
CS
I spent hours trying to find what is the good sample to use when you want to add a confirm script to button or anchors using RadWindow.
On buttons I use:
string js = string.Format("return radconfirm('{0}', event, null, null,null,'{1}');", msg, title);
if ( Btn.Attributes["onclick"] != null)
Btn.Attributes["onclick"] = js;
else Btn.Attributes.Add("onclick",js);
I found a sample on forums which seems to be related to previous RadControls, not for AJX.NET and I got problems when the button is using call back.
This sample is based on following script.
function ConfirmLoadHandler() |
{ |
var oldConfirm = radconfirm; |
//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){} |
} |
} |
} |
//We will need to modify the oldconfirm as well ???????? |
oldConfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle); |
} |
return false; |
} |
} |
But this script should be called after RadWindowManager declaration, so I use following code to add it on the last instructions of the page:
string scrpt = "ConfirmLoadHandler();";
AjaxManager.ResponseScripts.Add(scrpt);
And I get problems on callback: I am fearing the radconfirm function is replaced many times ? How to control this.
Is there a more recent sample we could use with last 2.1001 version to have a safely confirm with radWindows.
Thanks for clarification.
CS