More in this section

Forums / Developing with Sitefinity / Object reference not set error when referencing login layout template

Object reference not set error when referencing login layout template

2 posts, 0 answered
  1. Jeff
    Jeff avatar
    118 posts
    Registered:
    08 Jul 2011
    25 Apr 2012
    Link to this post
    Trying to customize the login widget with a custom layout template but I keep getting an object referenence not set error.

    What am I missing? Here's the error from the log:

    Message: HandlingInstanceID: c991f5d4-542b-4b58-a438-254e8df901a7

    An exception of type 'System.NullReferenceException' occurred and was caught.

    -----------------------------------------------------------------------------

    04/25/2012 13:33:41

    Type : System.NullReferenceException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

    Message : Object reference not set to an instance of an object.

    Source : Telerik.Sitefinity

    Help link :

    Data : System.Collections.ListDictionaryInternal

    TargetSite : Void OnInit(System.EventArgs)

    Stack Trace : at Telerik.Sitefinity.Security.Web.UI.LoginForm.OnInit(EventArgs e)

    at System.Web.UI.Control.InitRecursive(Control namingContainer)

    at System.Web.UI.Control.InitRecursive(Control namingContainer)

    at System.Web.UI.Control.InitRecursive(Control namingContainer)

    at System.Web.UI.Control.InitRecursive(Control namingContainer)

    at System.Web.UI.Control.InitRecursive(Control namingContainer)

    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


    And here's my code:
    <sf:LoginControl ID="LoginControl1" runat="server" LayoutTemplatePath="~/UserControls/Master/Layouts/Login.ascx" />

    <%@ Control Language="C#" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sitefinity" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <sitefinity:ClientLabelManager id="clientLabelManager" runat="server">
        <Labels>
            <sitefinity:ClientLabel ClassId="Labels" Key="LogoutUserConfirm" runat="server" />
            <sitefinity:ClientLabel ClassId="Labels" Key="UserNotSelected" runat="server" />
            <sitefinity:ClientLabel ClassId="Labels" Key="SelfLogoutUserConfirm" runat="server" />
        </Labels>
    </sitefinity:ClientLabelManager>
     
    <fieldset class="sfLoginWrp">
        <asp:Panel ID="loginPanel" runat="server">
            <asp:Label runat="server" ID="FailureText" EnableViewState="False" Visible="false" CssClass="sfFailure" />         
            <ol class="sfLoginFieldsWrp">
                <li class="sfLoginField">
                    <asp:Label ID="UserNameLabel" Text="<%$ Resources:Labels, Username %>" AssociatedControlID="UserName" runat="server" CssClass="sfTxtLbl" />
                    <asp:TextBox ID="UserName" AccessKey="u" runat="server" CssClass="sfTxt" />
                    <asp:RequiredFieldValidator ID="UserNameRequired" Display="Dynamic" ControlToValidate="UserName" ValidationGroup="LoginBox"
                        ErrorMessage="<%$ Resources:Labels, UsernameCannotBeEmpty %>" CssClass="sfValidator" runat="server">
                        <strong><asp:Literal ID="UserNameRequiredLiteral" runat="server" Text="<%$ Resources:Labels, UsernameCannotBeEmpty %>" /></strong>
                    </asp:RequiredFieldValidator>
                </li>
                <li class="sfLoginField">
                    <asp:Label ID="PasswordLabel" Text="<%$ Resources:Labels, Password %>" AssociatedControlID="Password" runat="server" CssClass="sfTxtLbl" />
                    <asp:TextBox ID="Password" TextMode="Password" AccessKey="p" runat="server" CssClass="sfTxt" />
                    <asp:RequiredFieldValidator ID="PasswordRequired" Display="Dynamic" ControlToValidate="Password" ValidationGroup="LoginBox"
                        ErrorMessage="<%$ Resources:Labels, PasswordCannotBeEmpty %>" CssClass="sfValidator" runat="server">
                        <strong><asp:Literal ID="PasswordRequiredLiteral" runat="server" Text="<%$ Resources:Labels, PasswordCannotBeEmpty %>" /></strong>
                    </asp:RequiredFieldValidator>
                </li>
                <li class="sfLoginField sfCheckBoxWrapper" id="rememberMeContainer" runat="server">
                    <asp:CheckBox runat="server" ID="RememberMe" />
                    <asp:Label ID="RememberMeTextLabel" Text="<%$ Resources:Labels, RememberMe %>" AssociatedControlID="RememberMe" runat="server" />
                </li>
            </ol>
            <div class="sfSubmitBtn">
                <asp:LinkButton ID="LoginButton" CommandName="Login" CssClass="sfLinkBtn sfSave" ValidationGroup="LoginBox" runat="server">
                    <strong class="sfLinkBtnIn"><asp:Literal ID="LoginButtonLiteral" runat="server" Text="<%$ Resources:Labels, LoginCaps %>"></asp:Literal></strong>
                </asp:LinkButton>
                <!-- do not remove this button. It is used for the default form submit (pressing enter) -->
                <div style="display: none;">
                    <asp:Button ID="hiddenSubmitButton" runat="server" CommandName="Login" ValidationGroup="LoginBox" />
                </div>
            </div>     
        </asp:Panel>
    </fieldset>

  2. Jeff
    Jeff avatar
    118 posts
    Registered:
    08 Jul 2011
    25 Apr 2012
    Link to this post
    Nevermind. I was using PublicControls\LoginControl.ascx from WidgetTemplates.zip in the SDK as a starter and I left out some sections.
2 posts, 0 answered