1

ModalPopupExtender が表示されている間、アニメーション効果を無効にするにはどうすればよいですか? これが私のコーディングです:

HTML

 <script language ="javascript" type="text/javascript">
    function pageLoad() {
        var mpe = $find("modalPopUp");
        //add shown will be fire when when the ModalPopupExtender had shown 
        mpe.add_shown(onShown);

    }
    function onShown() {
        var background = $find("modalPopUp")._backgroundElement;
        background.onclick = function () { $find("modalPopUp").hide(); }
    }
 </script>

<asp:UpdatePanel ID ="updatePanel" runat="server">
    <ContentTemplate>
<asp:Panel ID="Panel1" runat="server" BackColor="Azure">
   <asp:UpdatePanel ID="updatePanel2" runat="server"  UpdateMode="Conditional">
   <ContentTemplate>


    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Button" />
    <br />
    <br />
    <br />
    <br />
    <br />

   </ContentTemplate>
   </asp:UpdatePanel>

</asp:Panel>


     <!--Register modal pop up-->
    <asp:ModalPopupExtender ID="modalPopUp" runat="server" 
    TargetControlID="Button1" PopupControlID="Panel1" 
    BackgroundCssClass="overlay_style" BehaviorID="modalPopUp"  >
       <Animations>
        <OnShown>
          <FadeIn duration="0.5" Fps="100" />
        </OnShown>
    </Animations>
        </asp:ModalPopupExtender>
<asp:Button ID="Button1" runat="server" Text="Button" />
</ContentTemplate>
    </asp:UpdatePanel>

私のバックエンドコード:

 protected void Button2_Click(object sender, EventArgs e)
 {
     this.modalPopUp.Show();
 }

button2効果が繰り返されないようにするためにクリックしている間、アニメーションを無効にするにはどうすればよいですか?

4

1 に答える 1

2

サーバー側からアニメーションのプロパティにアクセスできます。したがって、プロパティを に設定して、繰り返さないようにすることができます(再度復元する必要がある場合は、アニメーションを変数に保存する可能性があります)。このようなもの:OnShownnull

protected void Button2_Click(object sender, EventArgs e)
{
    // Store the current "OnShown" animation for possible later use
    AjaxControlToolkit.Animation onShownAnim = modalPopup.OnShown;
    // Set the "OnShown" animation propert to null to disable the animation
    modalPopup.OnShown = null;

    modalPopup.Show(); // Now your popup shows without any animation, hooray!
}

に関する注意onShownAnim- 現在のプロパティを復元する必要がある場合は、ローカル変数よりも永続的なものを使用して現在のOnShownプロパティを保存することをお勧めしますが、アイデアは得られると思います =)

于 2011-12-13T14:49:46.003 に答える