0

I am new to Tridion and I need to remove the dropdown from the control and the moment i do that the file gives null exception error.

Control code:
<%@ Control Language="C#" AutoEventWireup="true" Inherits="xxx.Codebehind.Controls.Listing" %>
<%@ Register Assembly="xxx.Codebehind" Namespace="xxx.Codebehind.Utilities" TagPrefix="xxx" %>

    <section class="articlesList">
         <p><%=subHeading%></p>
         <h2><%=titleText%></h2>
        <div class="liner">
            <label>##resultsPerPage##:</label>    
            <asp:DropDownList runat="server" ID="ResultsPerPage" CssClass="resultsPerPage" AutoPostBack="true">
                <asp:ListItem Value="5">5</asp:ListItem>
                <asp:ListItem Selected="True" Value="10">10</asp:ListItem>
                <asp:ListItem Value="15">15</asp:ListItem>
                <asp:ListItem Value="20">20</asp:ListItem>
                <asp:ListItem Value="25">25</asp:ListItem>
                <asp:ListItem Value="30">30</asp:ListItem>
                <asp:ListItem Value="35">35</asp:ListItem>
                <asp:ListItem Value="40">40</asp:ListItem>
                <asp:ListItem Value="45">45</asp:ListItem>
                <asp:ListItem Value="50">50</asp:ListItem>
            </asp:DropDownList>    
        </div>
        <table class="layout">
            <thead>
                <tr>
                <th>##documentArticle##</th>
                <th>##date##</th>
                </tr>
            </thead>
            <tbody>
                <asp:ListView runat="server" ID="PressReleases" >
                    <LayoutTemplate>
                        <asp:PlaceHolder runat="server" ID="itemPlaceholder" />                                            
                    </LayoutTemplate>
                    <ItemTemplate>
                        <tr>
                            <td>
                                <ul class="linkList">
                                    <li>
                                        <a <%# ((PressReleaseItem)Container.DataItem).URLMarkup %> ><%# ((PressReleaseItem)Container.DataItem).Title %></a>
                                    </li>
                                </ul>
                            </td>
                            <td><%# ((PressReleaseItem)Container.DataItem).Date.ToString("dd MMM yyyy") %></td>
                        </tr>
                    </ItemTemplate>                           
                </asp:ListView>     
            </tbody>
        </table>

        </section>

I removed all the references of the dropdown from the codebehind. It doesn't give any error or even the page is fine. But the moment i remove the the dropdown from this file it gives null exception error.

The code that i commented from the codebehind is

//DropDownList ResultsPerPage = base.FindControl("ResultsPerPage") as DropDownList;
 //itemsPerPage = int.Parse(ResultsPerPage.SelectedValue);

Any idea what may be the issue or how these dropdowns are working?

1
  • 1
    I might be missing something here... don't really see anything related to Tridion in this question.
    – Nuno Linhares
    Commented Aug 11, 2016 at 12:27

1 Answer 1

2

The good news is that nothing in your question is specific to Tridion :) So you can probably search the internet for a solution without limiting yourself to the realm of Tridion.

Now for my suggestion on what might be going wrong: you either missed a reference to the drop-down (maybe in other code files) -- or you did not rebuild and copy the DLL to the website before requesting the page again.

The code in the code-behind file gets compiled into an assembly (DLL) and if that hasn't been updated on the website, it will still try to find the drop-down list in your markup (which is compiled just-in-time), resulting in a NullReferenceException.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.