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

Prevent flashing on custom command click.

4 Answers 96 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 24 Mar 2011, 12:07 AM
Hi all,

I have a custom command created like so:

DockCommand settingsCommand = new DockCommand();
settingsCommand.Name = "Local Settings";
settingsCommand.Text = "Local Settings";
settingsCommand.CssClass = "LocalSettings";
settingsCommand.AutoPostBack = false;
settingsCommand.OnClientCommand = "ShowLocalSettings";
Commands.Add(settingsCommand);

function ShowLocalSettings(sender, eventArgs) {
    radDock = sender;
    var oWindow = window.radopen(null, "LocalSettingsWindow");
    oWindow.center();
}


The RadWindow appears fine and everything works as expected, but, in the background I can see my page refreshing when I click the custom command button -- even though autopostback is set to false. My RadWindow doesn't flash, and it's modal so the background can't be interacted with, but it is still distracting to see it refreshing once when my RadWindow is already displayed.

Any ideas on why this would be happening?

4 Answers, 1 is accepted

Sort by
0
Accepted
Pero
Telerik team
answered on 24 Mar 2011, 05:25 PM
Hi Sean,

Do you set the RadDock.CommandsAutoPostBack property to true anywhere in your code? This property takes priority even though you have set DockCommand.AutoPostBack to false.

Regards,
Pero
the Telerik team
0
Sean
Top achievements
Rank 2
answered on 24 Mar 2011, 05:38 PM
Hi Telerik,

No, I do not. I also explicitly set this property to false in my RadDock constructor just to ensure nothing unintended is occurring. Can you think of any other reasons why postback would occur?

EDIT: Is it possible that because I have OnClientCommand set it will always postback in order to get the JavaScript to run?
0
Pero
Telerik team
answered on 29 Mar 2011, 03:47 PM
Hi Sean,

No, I can't think of any other reason why the page will postback when the command is clicked. Could you please confirm that a postback is actually occurring, because the RadWindow will be closed if a postback occurs? You could observe the page traffic in FF using FireBug, or if you have installed IE9 using the IEDevToolBar.

The JavaScript code is executed on the client, and there is no need of a trip to the server. It is possible however that the code executed in the OnClientCommand handler to post the page to the server. Could you give us the code of the handler method?

I tried to reproduce the problem locally but with no success:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="RadScriptManager1" runat="server">
    </asp:ScriptManager>
    <script type="text/javascript">
        function OnClientCommand(dock, args)
        {
            alert(1);
        }
    </script>
    <div>
        <telerik:RadDockLayout ID="RadDockLayout1" runat="server">
            <telerik:RadDockZone ID="RadDockZone1" runat="server" MinHeight="50px" Width="300px">
                <telerik:RadDock ID="RadDock1" runat="server" Title="RadDock-Title" Width="300px"
                    Height="300px">
                    <Commands>
                        <telerik:DockCloseCommand />
                        <telerik:DockCommand AutoPostBack="false" OnClientCommand="OnClientCommand" />
                    </Commands>
                    <ContentTemplate>
                        Dock's Content
                    </ContentTemplate>
                </telerik:RadDock>
            </telerik:RadDockZone>
        </telerik:RadDockLayout>
    </div>
    </form>
</body>
</html>

using System;
 
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        RadDock1.Title = DateTime.Now.ToString();
    }
}


Regards,
Pero
the Telerik team
0
Sean
Top achievements
Rank 2
answered on 29 Mar 2011, 09:06 PM
Hi Telerik,

I hunted down the issue. You were correct -- AutoPostBackCommand was set in a really far-off spot. Thanks for making me take a closer look at my own code!
Tags
Dock
Asked by
Sean
Top achievements
Rank 2
Answers by
Pero
Telerik team
Sean
Top achievements
Rank 2
Share this question
or