在google上搜索,我确实找不到一种非javascript的方式来显示和隐藏我的panel/updatepanel。
我确实有面板和更新面板,我想在按钮点击后动态地显示/隐藏它们,最好不要使用javascript,如果有的话,可以使用jQuery。
我发现的所有示例都消耗了大量代码,老实说,我不想因为这个而丢掉我的代码。
想法?
发布于 2010-06-26 17:02:56
你也可以使用多视图和里面的几个视图。通过这样做,您可以使用按钮控件来选择要显示的视图(面板)。下面的代码将在包含两个图像标记的两个视图之间切换。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 />https://stackoverflow.com/questions/3114621
复制相似问题