简体   繁体   中英

Removing CheckBoxList crashes page (ASP.NET)

I am working with a form that was previously built. I'm trying to remove a CheckBoxList that was already there. I don't need it on this form.

    <asp:CheckBoxList TabIndex="6" ID="ddlSchool" runat="server" RepeatDirection="Vertical" RepeatLayout="Table">
        <asp:ListItem Value="Item">Item</asp:ListItem>
        <asp:ListItem Value="Item">Item</asp:ListItem>
        <asp:ListItem Value="Item">Item</asp:ListItem>
        <asp:ListItem Value="Item">Item</asp:ListItem>
        <asp:ListItem Value="Item">Item</asp:ListItem>
        <asp:ListItem Value="Item">Item</asp:ListItem>
        <asp:ListItem Value="Item">Item</asp:ListItem>
        <asp:ListItem Value="Item">Item</asp:ListItem>
        <asp:ListItem Value="Item">Item</asp:ListItem>
    </asp:CheckBoxList></div>

...and when I remove it, I get this...

Render after CheckBoxList is removed

Thoughts?

You have to remove any code that references this list. Search for ddlSchool in your code-behind file (projectHelpRequest.aspx.cs) and comment out the lines that give you error...

When you created this NewName.aspx file, did you copy/paste the content from another file?

The error screen is telling you everything you need to know. Your NewName.aspx page is using the code behind for ProjectHelpRequest.aspx, not NewName.aspx. ProjectHelpRequest's code behind references ddlSchools, so by deleting it from NewName.aspx you're getting an error about it missing.

You need to make sure that in the directive at the top of NewName.aspx that you're setting the CodeBehind and/or Inherits values to inherit from NewName, not ProjectHelpRequest.

If all else fails, set visible=false. Use code or CSS. Nothing can break with this...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM