在按钮上显示部分单击 [英] Show Section On Button Click

查看:85
本文介绍了在按钮上显示部分单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当单击按钮时,如何显示页面的特定部分?请注意,该部分与按钮在同一页上(即,我不尝试显示新页面).

How do I show a particular section of a page when a button is clicked? Note that the section is on the same page as the button (i.e., I''m not trying to show a new page).

推荐答案

Multiviews


多视图允许在内容的各个部分之间轻松切换:

Multiviews


Multiviews allow for easily switching between sections of content:
<asp:MultiView runat="server">
    <asp:View runat="server">
        First Content
    </asp:View>
    <asp:View runat="server">
        Second Content
    </asp:View>
</asp:MultiView>


面板


当每个部分都不互斥时,面板是很好的选择:


Panels


Panels are good for when each section isn''t mutually exclusive:

<asp:Panel runat="server">
    Main Content
</asp:Panel>
<asp:Panel runat="server">
    Extra Content
</asp:Panel>


控件


您还可以显示/隐藏几乎任何ASP.NET或HTML控件,只要它上面带有 runat ="server" .只需将其可见属性设置为true或false.


Controls


You can also show/hide pretty much any ASP.NET or HTML control so long as it has a runat="server" on it. Just set its Visible property to true or false.

<div id="myDiv" runat="server">
    Extra Content
</div>


myDiv.Visible = false;


您可以使用窗格并将其设置为
You could use Panes and make them visible on click.


除上述其他答案外,您还可以使用JavaScript来实现.

单击按钮时,引发一个JavaScript方法.在该方法中,切换要隐藏/显示的部分/面板的显示/可见性.

使用按钮OnClientClick 属性进行操作.
Apart from other answers above, you can also achieve it using JavaScripts.

On button click, raise a JavaScript method. In that method toggle the display/visibility of the section/panel you want to hide/show.

Use buttons OnClientClick property to do it.


这篇关于在按钮上显示部分单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆