在谷歌搜索,我deffinitly找不到一個非JavaScript的方式來顯示和隱藏我的面板/更新面板。在ASP.NET上隱藏面板和Divs讓我瘋狂
我有面板和更新面板,我想在按下按鈕後顯示/隱藏它們,最好沒有javascript,或者如果是,使用jQuery。
我發現的所有示例都消耗了大量代碼,並且誠實地說,我不想因爲這個而丟掉我的代碼。
想法?
在谷歌搜索,我deffinitly找不到一個非JavaScript的方式來顯示和隱藏我的面板/更新面板。在ASP.NET上隱藏面板和Divs讓我瘋狂
我有面板和更新面板,我想在按下按鈕後顯示/隱藏它們,最好沒有javascript,或者如果是,使用jQuery。
我發現的所有示例都消耗了大量代碼,並且誠實地說,我不想因爲這個而丟掉我的代碼。
想法?
它並沒有真正採取了很多的代碼使用jQuery:
<input type="button" onclick="$('#blah').toggle();" />
<someelement id="blah"></someelement>
對於ASP.NET(從您的代碼修改):
<asp:Button ID="btnSubmit" runat="server" CssClass="button-login" OnClientClick="$('#login').toggle();" />
你還可使用多視圖和裏面的幾個意見。通過這樣做,您可以使用按鈕控件來選擇要顯示哪個視圖(面板)。下面的代碼將在包含兩個圖像標籤的兩個視圖之間切換。 ASP.NET表單(HTML)
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
<div>
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server">
<imgage = "my picture"> //add image tage here
</view>
<asp:View ID="View2" runat="server">
<imgage = "your picture"> //add image tage here
</view>
</asp: Multiview>
</div>
後面的代碼
Private button click toggleImageView
If multiview1.ActiveViewIndex=0 then
multiview1.ActiveViewIndex=1
ElseIf
multiview1.ActiveViewIndex=1 then
multiview1.ActiveViewIndex=0
EndIf
你也可以使用一個列表框選擇哪個視圖顯示在這樣 飛不過請注意,您的控制輸出選擇要顯示的視圖應位於多視圖控件之外,並在頁面加載時呈現。
<asp:DropDownList ID="DropDownList1" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
runat="server" AutoPostBack="True">
<asp:ListItem Value="0">View 1</asp:ListItem>
<asp:ListItem Value="1">View 2</asp:ListItem>
</asp:DropDownList><br />
如果沒有JavaScript,您不能這樣做。而jQuery基於JavaScript。 – 2010-06-24 23:26:36
我知道jQ是基於JS的,真的。但由於某種原因,我不能在我的代碼上使用ScriptManager.RegisterStartupScript來調用jQ,因爲它只在最後一行之後才被渲染......所以當我的腳本正在工作時,我無法隱藏和顯示我的面板(在這種情況下,數據庫)。 – alex 2010-06-24 23:30:03