在 ASP.NET 上隐藏面板和 Div 让我抓狂
在谷歌上搜索,我肯定找不到非JavaScript的方式来显示和隐藏我的面板/更新面板。
我确实有面板和更新面板,我想在单击按钮后动态显示/隐藏它们,最好不使用 javascript,或者如果是的话,使用 jQuery。
我发现的所有示例都消耗了大量代码,老实说,我不想仅仅因为这个就毁掉我的代码。
有想法吗?
Searching on google, i deffinitly can't find a non-javascript way to show and hide my panel/updatepanel.
I do have panels and updatepanels, I want to show/hide them on the fly, after a button click, preferably without javascript, or if so, with jQuery.
All the examples I found consumes a lot of code and honestly I don't want to crap out my code just because of this.
Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 jQuery 并不需要太多代码:
对于 ASP.NET(根据您的代码进行修改):
It doesn't really take a lot of code with jQuery:
For ASP.NET (modified from your code):
您也可以使用多视图和内部的几个视图。通过这样做,您可以使用按钮控件来选择要显示的视图(面板)。下面的代码将在包含两个图像标签的两个视图之间切换。
ASP.NET 表单 (HTML)
代码隐藏
您还可以使用列表框来选择要动态显示的视图,如下所示
但请注意,您选择要显示的视图的控件应该位于多视图控件之外,并且也应该在页面加载时呈现
You could as well use the multi view and a couple of views inside. By doing this you can use a button control to choose which view (panel) is to be displayed. The code below will toggle between two views containing two image tags.
ASP.NET Form (HTML)
CODE BEHIND
You may also use a list box to select which view to display on the fly like this
But note that your control o select which view to be displayed should be outside the multiview control and also be rendered on page load