微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 禁用asp图像按钮

我试图通过C#中的代码隐藏此表中的图像按钮(以便我可以在操作后隐藏它).

<asp:UpdatePanel runat="server" ID="upEmpListContainer" UpdateMode="Conditional"
    OnPreRender="upEmpListContainer_PreRender" OnInit="upEmpListContainer_Oninit">
    <ContentTemplate>

<asp:ListView ID="lvEmpList" OnItemDataBound="lvEmpList_ItemDataBound" OnDataBound="lvEmpList_DataBound"
            OnLayoutCreated="lvEmpList_LayoutCreated" runat="server" OnPreRender="lvEmpList_PreRender">
            <LayoutTemplate>
            <table class="formData_tb" cellspacing="0" style="margin: 0px; width: 100%;">
            <tr>
                <th colspan="9" class="currentManagerLabel" style="text-align: center">
                    <span>Currently displaying
                        <asp:Label ID="lblManager" runat="server" />
                        employees </span>
                    <asp:ImageButton ID="DrillUp" AlternateText="Move up in reporting heirarchy" runat="server"
                        CommandName="DrillDown" ImageUrl="~/images/icodoubleArrowUp.gif" OnCommand="butDrillDown_Click" />
                </th>
            </tr>
        </table>
</LayoutTemplate>
</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>

我似乎无法从其ID访问它.我试过DrillUp.Enabled = false;但Visual Studio说它无法解析符号’DrillUp’.

解决方法

您的图像按钮位于布局模板中,您无法直接访问它.

试试这个

ImageButton b = (ImageButton)lvEmpList.FindControl("DrillUp");
b.Visible = false;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐