This is a migrated thread and some comments may be shown as answers.

Radconfirm ok button not working

3 Answers 265 Views
Window
This is a migrated thread and some comments may be shown as answers.
Suresh Balan
Top achievements
Rank 1
Suresh Balan asked on 28 Nov 2008, 06:29 PM
Hi, I try to attach a radConfirm window to one button of the RadToolBar. I used the following sample javascript code to implement the thread execution blocking. On page_load I add attribute to one of buttons. My problem is the RadConfirm window Cancel button work but the OK button not working.  Looks like  callerObj.click();  didn't do anything.

Waiting for your reply.

Thanks!


RadToolBar1.FindItemByValue(

"2").Attributes("onclick") = "javascript:radconfirm('Are you sure?', event, 330,100,'','Confirm'); "

 

 


<
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>

3 Answers, 1 is accepted

Sort by
0
Accepted
Svetlina Anati
Telerik team
answered on 02 Dec 2008, 09:46 AM
Hello Suresh,

As far as I see form your code, you are using the approach we suggested in a code library to block the execution thread with radconfirm. I attached a sample demo which shows how this should be done, please examine it and use the same logic. In case you experience any further problems, please open a new support ticket and send me the same project, modified in order to reproduce the problem.


Sincerely yours,
Svetlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Suresh Balan
Top achievements
Rank 1
answered on 27 Jan 2009, 08:20 PM

Hi

I want this code can work on the button in the RadToolBar. But it's not working. Actually cancel button work, but the ok button is not clickable. Why?

Here is the html:
.......

 

<

 

telerik:RadToolBar ID="RadToolBar1" runat="server">

 

 

 

 

 

<Items>

 

 

 

 

 

<telerik:RadToolBarButton runat="server" Text="Delete Item" >                                        'need confirm window

 

 

 

 

 

</telerik:RadToolBarButton>

 

 

 

 

 

<telerik:RadToolBarButton runat="server" Text="Add Item" >                                           'don't need confirm window

 

 

 

 

 

</telerik:RadToolBarButton>

 

 

 

 

 

</Items>

 

 

 

 

 

</telerik:RadToolBar>

 

 

..........

Here is the code behind.

Protected

 

Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

 

If Not Page.IsPostBack Then

 

 

 

 

RadToolBar1.Items.FindItemByText(

"Delete Item").Attributes("onclick") = "javascript:radconfirm('Are you sure to delete this document and all the contents?', event, 330,100,'','Confirm'); "

 

 

 

 

 

End If

 

 

 

 

 

End Sub

 

Protected

 

Sub RadToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles RadToolBar1.ButtonClick

 

 

    If e.Item.Text = "Delete Item" Then

 

 

 

 

    Response.Write(

"Postback from asp:RadToolBar initiated--" & e.Item.Text)

 

 

    ElseIf e.Item.Text = "Add Item" Then

 

 

 

 

    Response.Write(

"Postback from asp:RadToolBar initiated--" & e.Item.Text)

 

 

    End If

 

 

 

 

 

End Sub

Thanks!

 

0
Georgi Tunev
Telerik team
answered on 29 Jan 2009, 11:48 AM
Hi Suresh Balan,

I believe that the following KB article will be of help:

http://www.telerik.com/support/kb/aspnet-ajax/window/using-radprompt-and-radconfirm-with-telerik-navigational-controls.aspx



Greetings,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Window
Asked by
Suresh Balan
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Suresh Balan
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or