Colin Bull
Top achievements
Rank 1
Colin Bull
asked on 25 May 2007, 02:55 PM
Im currently dynamicly creating a set of docks to a page, and i would like to have a confimation popup on the DockCloseCommand. Is this possilbe if so how do i implement it with dynamicly created dock objects.
6 Answers, 1 is accepted
0
Hello Colin Bull,
You should use a RadWindow as a confirm window to confirm whether RadDock should be closed or not. I am attaching a sample page demonstrating how to achieve the desired behavior both for dynamically created docks and static docks.
All the best,
Petya
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
You should use a RadWindow as a confirm window to confirm whether RadDock should be closed or not. I am attaching a sample page demonstrating how to achieve the desired behavior both for dynamically created docks and static docks.
All the best,
Petya
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
lchesnais
Top achievements
Rank 1
answered on 11 Jan 2008, 05:13 PM
[Please note I'm using version 2007.3.1218]
Hello Telerik,
I found this post while trying to implement a similar thing although I only wanted to handle the Command Close on the client side (no postback).
I wanted to add points :
1. Using Petya sample, I think it is usefull to add a CSS Class to the custom command that will handle Close command.
In the code-behind, a single additional line is needed :
2. I think that there is something missing in the JavaScript OpenConfirm1 function. In the sample below I added "args.set_cancel(true);" This call avoids the raise of the OnClientCommand event.
3. I would suggest that Telerik developpers introduce a new property to the DockCloseCommand object to let us handle the confirmation via a simple handler.
The proposed trick (or workaround) works OK but is not so easy to implement and might lead to incompatibilty if a future Prometheus changes some logic (Command name, Css class names or whatever).
BR, Laurent
Hello Telerik,
I found this post while trying to implement a similar thing although I only wanted to handle the Command Close on the client side (no postback).
I wanted to add points :
1. Using Petya sample, I think it is usefull to add a CSS Class to the custom command that will handle Close command.
In the code-behind, a single additional line is needed :
command.CssClass = "rdClose";
2. I think that there is something missing in the JavaScript OpenConfirm1 function. In the sample below I added "args.set_cancel(true);" This call avoids the raise of the OnClientCommand event.
function OpenConfirm1(sender, args) | |
{ | |
var callBackFn1 = function(arg) | |
{ | |
if (arg == true) | |
{ | |
sender.get_parent().doPostBack("Close"); | |
} | |
else | |
{ | |
args.set_cancel(true); | |
} | |
}; | |
var oWnd = radconfirm("Close RadDock?", callBackFn1); | |
} | |
3. I would suggest that Telerik developpers introduce a new property to the DockCloseCommand object to let us handle the confirmation via a simple handler.
The proposed trick (or workaround) works OK but is not so easy to implement and might lead to incompatibilty if a future Prometheus changes some logic (Command name, Css class names or whatever).
BR, Laurent
0
Hi lchesnais,
I just like to comment a bit your point #2. The code you added does not avoid the raise of the OnClientCommand event. The event is raised, then this line is executed
var oWnd = radconfirm("Close RadDock?", callBackFn1);
And here comes one important point - as stated in our documentation radconfirm does not block the execution thread. This means that if you have any code after var oWnd = radconfirm("Close RadDock?", callBackFn1); it will be executed. This is a different compared to the standard confirm behavior. All code that should or should not be executed depending on the radconfirm return value should be placed in callBackFn1. Also, the code you added is not really necessary because with the code I provided the commands do not force a postback when clicked so only their client-side handler is executed and you do not need to cancel it. If you however choose to close the dock in radconfirm, then a postback is forced so that the dock is closed on the server.
As far as your proposal is concerned - we will log it in our system and consider it when improving the control's behavior.
Regards,
Petya
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I just like to comment a bit your point #2. The code you added does not avoid the raise of the OnClientCommand event. The event is raised, then this line is executed
var oWnd = radconfirm("Close RadDock?", callBackFn1);
And here comes one important point - as stated in our documentation radconfirm does not block the execution thread. This means that if you have any code after var oWnd = radconfirm("Close RadDock?", callBackFn1); it will be executed. This is a different compared to the standard confirm behavior. All code that should or should not be executed depending on the radconfirm return value should be placed in callBackFn1. Also, the code you added is not really necessary because with the code I provided the commands do not force a postback when clicked so only their client-side handler is executed and you do not need to cancel it. If you however choose to close the dock in radconfirm, then a postback is forced so that the dock is closed on the server.
As far as your proposal is concerned - we will log it in our system and consider it when improving the control's behavior.
Regards,
Petya
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
VnDevil
Top achievements
Rank 2
answered on 28 May 2010, 09:50 AM
Hi Telerik,
when I run your CloseConfirm demo, it's has a Error: Object doesn't support this property or method at line
"sender.get_parent().doPostBack("Close");"
Please fix it
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CloseConfirm.aspx.cs" Inherits="Portal.Demo.RadControls.RadDock.CloseConfirm" %> |
<%@ 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 runat="server"> |
<title></title> |
</head> |
<body> |
<form id="form1" runat="server"> |
<div> |
<asp:ScriptManager ID="ScriptManager" runat="server"> |
</asp:ScriptManager> |
<telerik:RadDockLayout ID="RadDockLayout1" runat="server"> |
<telerik:RadDockZone ID="RadDockZone1" runat="server" Height="400px" MinHeight="200" |
Style="float: left; margin-right: 20px;" Width="300"> |
</telerik:RadDockZone> |
<telerik:RadDockZone ID="RadDockZone2" runat="server" Height="400px" MinHeight="200" |
Style="float: left;" Width="300"> |
<telerik:RadDock ID="RadDock2" runat="server" OnCommand="dock_Command" Text="Static dock" |
Title="RadDock2"> |
<Commands> |
<telerik:DockExpandCollapseCommand /> |
<telerik:DockCommand Name="Close" OnClientCommand="OpenConfirm1" Text="Close" /> |
</Commands> |
</telerik:RadDock> |
</telerik:RadDockZone> |
</telerik:RadDockLayout> |
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"> |
</telerik:RadWindowManager> |
</div> |
<script type="text/javascript"> |
function OpenConfirm1(sender, args) { |
var callBackFn1 = function(arg) { |
if (arg == true) { |
sender.get_parent().doPostBack("Close"); |
} |
}; |
var oWnd = radconfirm("Close RadDock?", callBackFn1); |
} |
</script> |
</form> |
</body> |
</html> |
using System; |
using System.Collections.Generic; |
using System.Linq; |
using System.Web; |
using System.Web.UI; |
using System.Web.UI.WebControls; |
using Telerik.Web.UI; |
namespace Portal.Demo.RadControls.RadDock |
{ |
public partial class CloseConfirm : System.Web.UI.Page |
{ |
protected override void OnInit(EventArgs e) |
{ |
Telerik.Web.UI.RadDock dock = new Telerik.Web.UI.RadDock(); |
DockCommand command = new DockCommand(); |
command.Text = "Close"; |
command.Name = "Close"; |
command.OnClientCommand = "OpenConfirm1"; |
dock.Commands.Add(command); |
dock.Text = "Dynamically Created Dock"; |
dock.Title = "MyDock"; |
dock.ID = "MyDock"; |
dock.Command += new DockCommandEventHandler(dock_Command); |
RadDockZone1.Controls.Add(dock); |
base.OnInit(e); |
} |
public void dock_Command(object sender, DockCommandEventArgs e) |
{ |
if (e.Command.Name == "Close") |
{ |
((Telerik.Web.UI.RadDock)sender).Closed = true; |
} |
} |
protected void Page_Load(object sender, EventArgs e) |
{ |
} |
} |
} |
0
Hello,
Could you please tell us, which version of RadControls for ASP.NET AJAX you are using? The following code works with the latest DLL:
Regards,
Pero
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Could you please tell us, which version of RadControls for ASP.NET AJAX you are using? The following code works with the latest DLL:
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
asp:ScriptManager
ID
=
"ScriptManager"
runat
=
"server"
>
</
asp:ScriptManager
>
<
telerik:RadDockLayout
ID
=
"RadDockLayout1"
runat
=
"server"
>
<
telerik:RadDockZone
ID
=
"RadDockZone1"
runat
=
"server"
Height
=
"400px"
MinHeight
=
"200"
Style
=
"float: left; margin-right: 20px;"
Width
=
"300"
>
</
telerik:RadDockZone
>
<
telerik:RadDockZone
ID
=
"RadDockZone2"
runat
=
"server"
Height
=
"400px"
MinHeight
=
"200"
Style
=
"float: left;"
Width
=
"300"
>
<
telerik:RadDock
ID
=
"RadDock2"
runat
=
"server"
Text
=
"Static dock"
Title
=
"RadDock2"
OnCommand
=
"dock_Command"
>
<
Commands
>
<
telerik:DockExpandCollapseCommand
/>
<
telerik:DockCommand
Name
=
"CustomClose"
OnClientCommand
=
"OpenConfirm1"
Text
=
"Close"
CssClass
=
"rdClose"
/>
</
Commands
>
</
telerik:RadDock
>
</
telerik:RadDockZone
>
</
telerik:RadDockLayout
>
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
runat
=
"server"
>
</
telerik:RadWindowManager
>
</
div
>
<
script
type
=
"text/javascript"
>
function OpenConfirm1(sender, args)
{
var callBackFn1 = function(arg)
{
if (arg == true)
{
sender.set_closed(true);
sender.doPostBack(args.Command.get_name());
}
};
var oWnd = radconfirm("Close RadDock?", callBackFn1);
}
</
script
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Web.UI;
using
System.Web.Caching;
public
partial
class
Default_Dock : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
public
void
dock_Command(
object
sender, DockCommandEventArgs e)
{
if
(e.Command.Name ==
"CustomClose"
)
{
((Telerik.Web.UI.RadDock)sender).Closed =
true
;
Page.Title =
"Close"
;
}
}
}
Regards,
Pero
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
VnDevil
Top achievements
Rank 2
answered on 02 Jun 2010, 06:06 PM
Thanks admin, it worked :D