Prevent flashing on custom command click.

5 posts, 1 answers
  1. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 23 Mar 2011 Link to this post

    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?

  2. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 24 Mar 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 24 Mar 2011 Link to this post

    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?
  5. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 29 Mar 2011 Link to this post

    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
  6. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 29 Mar 2011 Link to this post

    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!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017