vb.net 在asp.net中使面板可见或不可见

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16224576/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 13:24:16  来源:igfitidea点击:

make a panel visible or invisible in asp.net

asp.netvb.netpanelvisible

提问by Vishal

I have a button on my page. I have a panel on my page. I also have a multiline textbox on my page.

我的页面上有一个按钮。我的页面上有一个面板。我的页面上还有一个多行文本框。

Now I want to make panel visible and invisible without disturbing the position of the textbox below. Just like notification panel on facebook.

现在我想让面板可见和不可见,而不会干扰下面文本框的位置。就像 facebook 上的通知面板一样。

Here is the code to make panel visible/invisible :

这是使面板可见/不可见的代码:

Protected Sub btnReauests_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnReauests.Click

    If pnlShowRequests.Visible = True Then
        pnlShowRequests.Visible = False
    Else
        pnlShowRequests.Visible = True
    End If
End Sub

I have also tried setting the z-order style of the panel like this

我也试过像这样设置面板的 z-order 样式

<asp:Panel ID="pnlShowRequests" runat="server" style =" z-index : 1; position : relative; top: 0px; left: 255px; width: 206px; height: 200px;" Visible="False">
            </asp:Panel>

回答by Joe Raio

You would have to wrap the panel in it's own div and set the height. This way when you make it invisible, it wont affect the position of the elements around it.

您必须将面板包裹在它自己的 div 中并设置高度。这样当你让它不可见时,它不会影响它周围元素的位置。

For example:

例如:

<div style="height: 100px;">
<asp:panel></asp:panel>
</div>
<asp:textbox runat="server"></asp:textbox>