More in this section

Forums / Developing with Sitefinity / Sitefinity 4 LoginControl LayoutTemplate Code

Sitefinity 4 LoginControl LayoutTemplate Code

3 posts, 1 answered
  1. Thomas
    Thomas avatar
    223 posts
    Registered:
    19 Jan 2011
    02 Nov 2011
    Link to this post
    Hi,

    I'd like to have the default code of the LoginControl LayoutTemplate, to have a base to start from.

    I saw this site that apparently has the code, but I cannot access it. It's blocked by my company's proxy.
    Also, it could be good to add the code to the concerned documentation page.

    Thanks.
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    02 Nov 2011
    Link to this post
    a complete set of the default templates for all controls are available in the Sitefinity SDK. They will be in the folder

    C:\Program Files (x86)\Telerik\Sitefinity 4.2\SDK\Content\Resources

    the logincontrol is there along with the default templates of pretty much every templated control.

    In case you are in immediate need here is the code from that control template.

    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI"
        TagPrefix="sitefinity" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <%@ Control Language="C#" %>
      
    <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 id="ProvidersHolder" runat="server" class="sfLoginField">
                <asp:Label ID="ProvidersLabel" Text="<%$ Resources:Labels, Provider %>" AssociatedControlID="ProvidersList"
                    runat="server" CssClass="sfTxtLbl" />
                <asp:DropDownList ID="ProvidersList" AutoPostBack="false" AccessKey="l" runat="server" />
            </li>
            <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>
    <asp:Panel ID="userListPanel" runat="server" Visible="false">
        <p class="sfNeutral"><asp:Literal ID="userLimitLabel" runat="server" Text="<%$ Resources:Labels, UserLimitLabel%>" /></p>
        <asp:DropDownList ID="userListChoice" runat="server" />           
        <div class="sfSubmitBtn">
            <asp:LinkButton ID="logoutButton" runat="server" OnClientClick="return AlertLogOut();" CssClass="sfLinkBtn">
                <strong class="sfLinkBtnIn">
                    <asp:Literal ID="LogoutButtonLiteral" runat="server" Text="<%$ Resources:Labels, LogoutButtonText%>"></asp:Literal>
                </strong>
            </asp:LinkButton>
        </div>
              
    </asp:Panel>
      
    <asp:Panel ID="selfLogoffPanel" runat="server" Visible="false">
        <p class="sfNeutral"><asp:Literal ID="selfLogoffLabel" runat="server" Text="<%$ Resources:Labels, SelfLogoffLabel%>" /></p>
        <div class="sfSubmitBtn">
            <asp:LinkButton ID="selfLogoutButton" runat="server" OnClientClick="return AlertSelfLogOut();" CssClass="sfLinkBtn">
                <strong class="sfLinkBtnIn">
                    <asp:Literal ID="LogoutOtherUserAndEnterLiteral" runat="server" Text="<%$ Resources:Labels, SelftLogoutButtonText%>"></asp:Literal>
                </strong>
            </asp:LinkButton>
            <asp:LinkButton ID="selfLogoutCancelButton" runat="server" Text="<%$ Resources:Labels, Cancel%>" CssClass="sfCancel" />
        </div>
              
    </asp:Panel>
      
    <asp:Panel ID="denyLogonPanel" runat="server" Visible="false">
        <p class="sfNeutral"><asp:Literal ID="denyLogonMesage" runat="server" Text="<%$ Resources:Labels, DenyLogonMesage%>" /></p>
        <p><asp:Literal ID="loginRetryMessage" runat="server" Text="<%$ Resources:Labels, LoginRetryMessage%>" /></p>
             
    </asp:Panel>
      
    <asp:PlaceHolder ID="loginLinksHolder" runat="server">
        <div class="sfLoginHelp">
            <asp:Literal ID="HelpTitleLiteral" runat="server" Text="<%$ Resources:Labels, Help %>" />:
            <a id="PasswordRecoveryLink" href="~/Sitefinity/Login/PasswordRecovery" runat="server" onclick="toggleSmtpErrorMessage();">
                <asp:Literal ID="PasswordRecoveryTextLiteral" runat="server" Text="<%$ Resources:Labels, ForgotYourPassword %>" />
            </a>
            <a id="ChangePasswordLink" href="~/Sitefinity/Login/ChangePassword" runat="server" onclick="toggleSmtpErrorMessage();">
                <asp:Literal ID="ChangePasswordTextLiteral" runat="server" Text="<%$ Resources:Labels, ChangePassword %>" />
            </a>
            <a id="CreateUserLink" href="~/Sitefinity/Login/Register" runat="server">
                <asp:Literal ID="RegisterUserTextLiteral" runat="server" Text="<%$ Resources:Labels, Register %>" />
            </a>
            <a id="HelpLink" href="~/Sitefinity/Help/UsersAndRoles/LoggingIn" runat="server">
                <asp:Literal ID="HelpLinkLiteral" runat="server" Text="<%$ Resources:Labels, Help %>" />
            </a>        
        </div>
    </asp:PlaceHolder>
      
    <div id="smtpNotSetContainer" class="sfNeutral sfDetailedInfo" style="display:none;">   
        <p>
            <strong><asp:Literal runat="server" ID="ErrorMessageNoSmtpConfigLiteral" Text="<%$ Resources:ErrorMessages, TheSystemHasNotBeenConfiguredToSendEmails %>" /></strong>
        </p>
        <ul>
            <li><asp:Literal runat="server" ID="ErrorMessageContactAdminToResetYourPasswordLiteral" Text="<%$ Resources:ErrorMessages, ContactAnAdministratorToResetYourPasswordManually %>" /></li>
            <li>
                <asp:Literal runat="server" ID="ErrorOrAskAnAdministratorToConfigureTheSystemLiteral" Text="<%$ Resources:ErrorMessages, OrAskAnAdministratorToConfigureThSystem %>" /> 
                <a href="javascript:void(0)" onclick="toggleVisibility('smtpNotSetSolution')">
                    <asp:Literal runat="server" ID="ErrorMessageSmtpDetailsTitle" Text="<%$ Resources:ErrorMessages, Details %>" />
                </a>
            </li>
        </ul>
        <div id="smtpNotSetSolution" class="sfDetailedHowTo" style="display: none; ">
            <p><asp:Literal runat="server" ID="ErrorMessageSmtpSettingsNotSetLiteral" Text="<%$ Resources:ErrorMessages, SmtpSettingsAreNotSet %>" /></p>
            <p><strong><asp:Literal runat="server" ID="ErrorMessageHowToSetSmtpLiteral" Text="<%$ Resources:ErrorMessages, HowToSetSMTP %>" /></strong></p>
            <ol>
                <li><asp:Literal runat="server" ID="Literal15" Text="<%$ Resources:ErrorMessages, GoToSettingsConfiguration %>" /></li>
                <li><asp:Literal runat="server" ID="Literal16" Text="<%$ Resources:ErrorMessages, SelectSystemSMTPSettings %>" /></li>
            </ol>
        </div>
    </div>
      
    <div id="smtpPermissionDeniedContainer" class="sfNeutral sfDetailedInfo" style="display:none;">
        <h3>
            <asp:Literal runat="server" ID="ErrorMessageTheSysIsNotPermittedToSendEmailsLiteral" Text="<%$ Resources:ErrorMessages, TheSystemHasIsNotPermittedToSendEmails %>" />
        </h3>
        <ul>
            <li><asp:Literal runat="server" ID="ErrorMessageContactAdminToResetYourPasswordSmtpLiteral" Text="<%$ Resources:ErrorMessages, ContactAnAdministratorToResetYourPasswordManually %>" /></li>
            <li>
                <asp:Literal runat="server" ID="ErrorOrAskAnAdministratorToConfigureTheSystemSmtpLiteral" Text="<%$ Resources:ErrorMessages, OrAskAnAdministratorToConfigureThSystem %>" /> 
                <a href="javascript:void(0)" onclick="toggleVisibility('smtpPermissionsDeniedDetails')">
                    <asp:Literal runat="server" ID="ErrorMessageSmtpPermissionDeniedDetailsTitle" Text="<%$ Resources:ErrorMessages, Details %>" />
                </a>
            </li>
        </ul>
        <div id="smtpPermissionsDeniedDetails" class="sfDetailedHowTo" style="display: none; ">
            <p><asp:Literal ID="SmtpPermissionErrorMessage" runat="server" /></p>        
        </div>
    </div>
    </fieldset>
      
    <asp:HiddenField id="logoutUser" runat="server" value="" />
    <asp:HiddenField id="loginTicket" runat="server" value="" />
    <asp:HiddenField id="mode" runat="server" value="" />
    <asp:HiddenField id="smtpSettingsAreSet" runat="server" value="" />
    <asp:HiddenField id="smtpPermissionDenied" runat="server" value="" />
      
    <telerik:RadCodeBlock runat="server">
    <script type="text/javascript">
      
        var userChoices;
        var smtpSettingsAreSet;
        var smtpPermissionDenied;
      
        function pageLoad() {
            userChoices = $find("<%= userListChoice.ClientID %>");
            smtpSettingsAreSet = getBooleanHiddenField("<%= smtpSettingsAreSet.ClientID %>");
            smtpPermissionDenied = getBooleanHiddenField("<%= smtpPermissionDenied.ClientID %>");
        }
      
        function getBooleanHiddenField(id) {
            var field = $get(id);
      
            if (field !== null && field.value) {
                return Boolean.parse(field.value);
            }
      
            return false;
        }
      
        function toggleVisibility() {
            var elem = arguments[0] ? document.getElementById(arguments[0]) : this;
            if (elem.style.display == "block") {
                elem.style.display = "none";
            }
            else {
                elem.style.display = "block";
            }
        }
      
        function toggleSmtpErrorMessage() {
            if (!smtpSettingsAreSet) {
                toggleVisibility('smtpNotSetContainer');
            } else if (smtpPermissionDenied) {
                toggleVisibility('smtpPermissionDeniedContainer');
            }
        }
      
        function AlertSelfLogOut() {
            var clientLabelManager = $find('<%= clientLabelManager.ClientID %>');
            var result = confirm(clientLabelManager.getLabel('Labels', 'SelfLogoutUserConfirm'));
            return result;
        }
      
        function AlertLogOut() {
      
            var value = userChoices.get_value();
            var clientLabelManager = $find('<%= clientLabelManager.ClientID %>');
            if (value == null || value.length == 0) {
                alert(clientLabelManager.getLabel('Labels', 'UserNotSelected'));
                return false;
            }
      
            var selectedItemId = userChoices.get_value(); // selectedItem[0].id;
            var result = confirm(clientLabelManager.getLabel('Labels', 'LogoutUserConfirm'));
      
            if (result) {
                $get('<%= logoutUser.ClientID %>').value = value;
      
            }
            return result;
        }
      
    </script>
    </telerik:RadCodeBlock>

    I hope this is helpful!
    Answered
  3. Thomas
    Thomas avatar
    223 posts
    Registered:
    19 Jan 2011
    02 Nov 2011
    Link to this post
    Thank you, much appreciated.
3 posts, 1 answered