Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在asp.net中隐藏内容_C#_Asp.net - Fatal编程技术网

C# 在asp.net中隐藏内容

C# 在asp.net中隐藏内容,c#,asp.net,C#,Asp.net,有没有一种方法可以隐藏asp.net中的一段代码,使其仅在出现问题时才可见 我有这个,但不起作用 <asp:DropDownList ID="drop" runat="server" Width="100" Height="25" BackColor="#CEECF5" CssClass="Selection"> <asp:ListItem Text="Rock" Value="1" /> <asp:ListItem Text="Paper" Value

有没有一种方法可以隐藏asp.net中的一段代码,使其仅在出现问题时才可见

我有这个,但不起作用

<asp:DropDownList ID="drop" runat="server" Width="100" Height="25" BackColor="#CEECF5" CssClass="Selection">
   <asp:ListItem Text="Rock" Value="1" />
   <asp:ListItem Text="Paper" Value="2" />
   <asp:ListItem Text="Scissor" Value="3" />
   <asp:ListItem Text="Lizard" Value="4" />
   <asp:ListItem Text="Spock" Value="5" />
</asp:DropDownList>
   <asp:Button Text="Play Hand" ID ="play" runat="server" BackColor="WhiteSmoke" Width="100" Height="25" CssClass="Button"/>

<asp:View ID="GameResults" ViewStateMode="Disabled">
   <br /> 
     <table>
        <tr>
          <td><asp:Image ID="PlayedHand" runat="server"  /></td>
          <td><asp:Image ID="RandomHand" runat="Server"  /></td>
        </tr>
        <tr>
          <td><asp:Label ID="PlayedLabel" Text="You played ....." runat="server" /></td>
          <td><asp:Label ID="RandomLabel" Text="Opponent played ....." runat="server" /></td>
        </tr>
    </table>
</asp:View>


我正在寻找一种方法,使结果只出现在按下按钮,游戏进行评估

我知道我可以处理单个元素,但这对HTML表标记没有帮助。所以我更喜欢将整个对象封装起来


有没有办法隐藏整个内容块

在GameResults视图中,将所有内容包装在一个div中:

<div id="divResults" runat="server" hidden="true">

将所有内容包装在ASP:Literal控件中,然后将其visible属性设置为false。这不起作用。当我尝试时,我得到了“'System.Web.UI.WebControls.Literal'不允许子控件。”啊,是的,你有图像和标签。对不起,我没看到。
If (game is evaluated) then divResults.hidden= false