3

Consider the following scenario:

MasterpageFile1:

<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Frame.master.vb" Inherits="Project.Frame" ClientIDMode="Static" %>
<!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" name="form1">
        <asp:ContentPlaceHolder ID="BodyPlaceHolder" runat="server">
        </asp:ContentPlaceHolder>
    </form>
</body>
</html>

Nested Masterpagefile:

<%@ Master Language="VB" MasterPageFile="/Project/Code/MasterPages/Frame.Master" CodeBehind="Master2.master.vb" Inherits="Project.Master2" %>
<asp:Content ID="Content2" ContentPlaceHolderID="BodyPlaceHolder" runat="server">
    <input type="submit" id="btSubmit" runat="server" value="start" class="input" />
    <asp:UpdatePanel ID="up" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <div>CALCULATION RESULT GETS DISPLAYED HERE</div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btSubmit" />
        </Triggers>
    </asp:UpdatePanel>
    <ajaxToolkit:UpdatePanelAnimationExtender ID="upae" runat="server" TargetControlID="up">
        <Animations>
            <OnUpdating>
                <Sequence>
                    <ScriptAction FPS="20" Duration="0.5" script="DoSomething();" />
                </Sequence>
            </OnUpdating>
            <OnUpdated>
                <Parallel>
                    <ScriptAction FPS="20" Duration="0" script="DoSomethingElse();" />
                </Parallel>
            </OnUpdated>
        </Animations>
    </ajaxToolkit:UpdatePanelAnimationExtender>
</asp:Content>

An ASPX-Page which loads some Styles.

And the follwing jQuery code:

$(document).ready(function () {
    $("#btSubmit").click();
});

This Code triggers the UpdatePanel to Refresh. The OnUpdating Animation is playing, the Server does some calculation stuff and sends the result to the client. The client builds in the result, but the OnUpdatedAnimation nevers plays.

If i change the jQuery code to the follwing, it works fine.

$(document).ready(function () {
    setTimeout(function () {
        $("#btSubmit").click();
    }, 1500);
});

May someone can tell me, why this happens and how to achieve, that the calculation starts when the DOM is ready and not 1.5 seconds later?

Kind Regards, Sören

4

1 回答 1

0

我相信这种行为的原因是当btSubmit点击发生部分回发时,并非所有客户端对象都被初始化。

尝试使用这个脚本(把它放在ScriptManager控制之后):

Sys.Application.add_load(applicationLoadHandler);

function applicationLoadHandler(sender, args) {
     if (args.get_isPartialLoad() !== true) {
          $("#btSubmit").click();
     }
}
于 2012-08-22T10:09:10.873 回答