2017-04-14 74 views
0

親愛的我所有我有我的網頁中的多個ASP面板設置爲可見= false在頁面加載和打開時,特定的linkbutton被點擊哪些工作正常,但現在我想給它一個慢動作效果或相應地展開效果。任何人都可以分享他們的經驗。如何給崩潰和展開效果面板單擊事件

protected void LinkButton3_Click(object sender, EventArgs e) 
{ 
    pnlWall.Visible = true; 
    pnlShareHome.Visible = false; 
} 

回答

0

您可以使用jQuery來顯示和隱藏面板(這只是<div>'s在HTML)。它具有滑動的可能性並保存到服務器的往返行程。

<asp:Panel ID="Panel1" runat="server" style="display: none;"> 
    content 
</asp:Panel> 

<input type="button" value="Slide Panel" onclick="slidePanel('<%= Panel1.ClientID %>')" /> 

<script type="text/javascript"> 
    function slidePanel(div) { 
     if ($('#' + div).css('display') == 'none') { 
      $('#' + div).slideDown('medium', function() { }); 
     } else { 
      $('#' + div).slideUp('medium', function() { }); 
     } 
    } 
</script> 

不過,如果你需要做的,因爲在Panel1內容的回傳,你可以做的時候調用slidePanel功能。

protected void Button1_Click(object sender, EventArgs e) 
{ 
    Panel1.Visible = true; 

    //set the dom visibility to none 
    Panel1.Attributes.Add("style", "display:none"); 

    //call the function to slide the panel open 
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "slidePanel", "slidePanel('" + Panel1.ClientID + "')", true); 

    //or with a 1 second delay (1000 ms) 
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "slidePanel", "setTimeout(function() { slidePanel('" + Panel1.ClientID + "'); }, 1000);", true); 
} 
+0

首先感謝這個的,這是工作的罰款對我,但我也想瓦解它回來時,我點擊關閉按鈕,我如何做到這一點? –

+0

通過做完全相同的事情。 'slidePanel'函數檢查div是否打開或關閉,並通過再次滑動來反轉它。如果你想在PostBack上做,你必須將'Panel1.Attributes'改爲'display:block' – VDWWD