We have so difficulties with the AutoPostBack of DockCommand.
As i work on the dynamic docks i add a command to the dock and update panel, i need it to postback after the client opens a rad window.
the opening of the rad window and close is ok, but after it closes i need to do the post back.
i tried to set it to true on client side and do the doPostBack but it returns this error:
Microsoft JScript runtime error: Object doesn't support this property or method
How can i do the postback of a command after the client side command?
Thanks,
Shimon
5 Answers, 1 is accepted
RadDock dock = new RadDock();
// Do some setup on the dock
dock.AutoPostBack = true;
dock.Command += new DockCommandEventHandler(dock_Command);
Then code up your event handler:
void dock_Command(object sender, DockCommandEventArgs e)
{
if (e.Command.GetType() == typeof(DockCloseCommand))
{
//Do some stuff if it was a close.
}
}
That should work. If it doesn't you might have to explicitly set the Close Command to AutoPostBack = true.
If that's the case, then during dock creation, you can just cycle over the dock.Commands collection and set the DockCloseCommand to AutoPostBack.
Hello,
1. I create a dynamic dock with a command:
private RadDock CreateRadDock(string Title)
{
int docksCount = CurrentDockStates.Count;
RadDock dock = new RadDock();
dock.ID = string.Format("RadDock{0}", docksCount);
dock.Title = Title;
dock.Text = string.Format("Added at {0}", DateTime.Now);
dock.UniqueName = Guid.NewGuid().ToString();
dock.Width = Unit.Pixel(400);
dock.Command += new DockCommandEventHandler(dock_Command);
dock.Commands.Add(new DockCloseCommand());
DockCommand DockCommand = new DockCommand();
DockCommand.AutoPostBack = true;
DockCommand.OnClientCommand = "OpenMasterBoxEditor";
DockCommand.Name = "Edit";
dock.Commands.Add(DockCommand);
return dock;
}
void dock_Command(object sender, DockCommandEventArgs e)
{
throw new Exception("The method or operation is not implemented.");
}
2. I add a postback trigger:
private void CreateDockCommandTrigger(RadDock dock)
{
AsyncPostBackTrigger CommandTrigger = new AsyncPostBackTrigger();
CommandTrigger.ControlID = dock.ID;
CommandTrigger.EventName = "Command";
UpdatePanel2.Triggers.Add(CommandTrigger);
}
3. On client side I open a rad window as a dialog with the command:
OnClientCommand = "OpenMasterBoxEditor";
4. after I close the rad window I want the rad dock command to postback. It doesn't.
All the clint side public methods don’t work:
var cmd = radDock.getCommand("Edit ");
cmd.doPostBack();
it returns:
Microsoft JScript runtime error: Object doesn't support this property or method
On every client side method.
can you help with that?
Thanks,
Shimon
Others may have some ideas, but the only suggestion I can give further is that perhaps what you are trying to do can be done an alternate way. You might look at the logic flow of the actions and perhaps there is something else that can be causing the PostBack instead of tying it to the close of the window and forcing it on the Dock.
We truly apologize for the delayed answer. So I will not waste more time but get straight to the point. Here is our suggestion:
[ASPX]
<script type="text/javascript">
function OpenMasterBoxEditor(sender, args)
{
var oWnd = window.radopen(null, "RadWindow1");
oWnd.Argument = sender.get_parent();
return false;
}
function OnClientClose(radwindow)
{
var dock = radwindow.Argument;
dock.doPostBack("Edit");
}
</script>
where we have removed DockCommand.AutoPostBack = true; from code-behind. The rest of the code is just like our Dynamically Created Docks online example plus your code. I am attaching the project so you can test with it.
Kind regards,
Petya
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank you,
Shimon