我有一个标准的搜索场景:用户输入搜索参数并单击搜索按钮-结果显示在下面的面板中。我要做的是根据搜索结果是否可用来控制面板的可见性。我尝试按如下方式对面板进行编码,但在运行时会遇到一个分析错误。
<asp:Panel ID="ResponsePanel" Visible="<%= Model != null %>" runat="server"> ... </asp:Panel>
我得到的分析错误是:
Cannot create an object of type 'System.Boolean' from its string representation '<%= Model != null %>' for the 'Visible' property.
如何根据模型的可用性切换面板?
<asp:panel>
<% if(! Model.HasValue){ %> <%: Html.Partial("WhatWouldGoInYourPanel") %> <% } %>
Views/Shared Views/[ControllerName]
Views/Shared
Views/[ControllerName]