Registration widget problem

Posted by Community Admin on 04-Aug-2018 16:50

Registration widget problem

All Replies

Posted by Community Admin on 20-Feb-2012 00:00

Hi

I am try to add a custom field to the registration widget. I have followed instructions in related threads and can add field to the form with;

     <sf:TextField ID="CustomId" runat="server" DataFieldName="CustomId" DisplayMode="Write" Title="ID" CssClass="sfregisterField sfregisterUserName" WrapperTag="li">
      </sf:TextField>

when the form is submitted i get the following error;

Could not find the specified key "Type does not contain property with that name" or class id "ErrorMessages".

if i remove the ID from the textfield, the submission works and adds data to the database but no data is added to the 'customId' field.

Any advice on this greatly appreciated.

Posted by Community Admin on 21-Feb-2012 00:00

Hi,

When adding a custom field that acceps a value and saves it in the database there will be no added implementation for this field. A csutom registration control will be required.

 I attached a short video and sample implementation that you should extend depending on your needs.
You need to create a custom control that inherits from RegistrationForm class. There is a virtual method TryCreateUser that you can override to get the id of the newly created user and then work with it. There is also a virtual RegisterButton_Click which you can use to subscrine for the click event of the registration button.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.Sitefinity.Security.Web.UI;
  
namespace Telerik.Sitefinity.Samples1
    public class RegistrationFormCustom : RegistrationForm
    
  
        protected override string LayoutTemplateName
        
            get
            
               return null;
            
        
  
        public override string LayoutTemplatePath
        
            get
            
                return RegistrationFormCustom.layoutTemplatePath;
            
              
        
  
        protected override void ConfirmRegistration(Security.UserManager userManager, Security.Model.User user)
        
  
            var userID = user.Id;
            base.ConfirmRegistration(userManager, user);
        
  
        private const string layoutTemplatePath = "~/SfSamples/Telerik.Sitefinity.Samples1.Resources.RegistrationForm.ascx";
    
template
<%@ Control Language="C#" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Fields" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sfvalidation" Namespace="Telerik.Sitefinity.Web.UI.Validation.Definitions" Assembly="Telerik.Sitefinity"%>
  
<fieldset class="sfregisterFormWrp">
    <asp:Panel ID="formContainer" runat="server" DefaultButton="registerButton">
        <ol class="sfregisterFieldsList">
           Custom Field 1
           <asp:TextBox runat="server" ID="TextBox1"></asp:TextBox>
            Custom Field 2
           <asp:TextBox runat="server" ID="TextBox2"></asp:TextBox>
  
            <sf:TextField ID="firstName" runat="server" DataFieldName="FirstName" DataItemType="Telerik.Sitefinity.Security.Model.SitefinityProfile" DisplayMode="Write" Title="<%$ Resources:Labels, FirstName %>" CssClass="sfregisterField sfregisterFirstName" WrapperTag="li" />
            <sf:TextField ID="lastName" runat="server" DataFieldName="LastName" DataItemType="Telerik.Sitefinity.Security.Model.SitefinityProfile" DisplayMode="Write" Title="<%$ Resources:Labels, LastName %>" CssClass="sfregisterField sfregisterLastName" WrapperTag="li" />
            <sf:TextField ID="email" runat="server" DataFieldName="Email" DisplayMode="Write" Title="<%$ Resources:Labels, Email %>" CssClass="sfregisterField sfregisterEmail" WrapperTag="li">
                <ValidatorDefinition MessageCssClass="sfError" Required="true" ExpectedFormat="EmailAddress"/>
            </sf:TextField>
            <sf:TextField ID="userName" runat="server" DataFieldName="UserName" DisplayMode="Write" Title="<%$ Resources:Labels, UserName %>" CssClass="sfregisterField sfregisterUserName" WrapperTag="li">
                <ValidatorDefinition MessageCssClass="sfError" Required="true"/>
            </sf:TextField>
            <sf:TextField ID="password" runat="server" DisplayMode="Write" Title="<%$ Resources:Labels, Password %>" IsPasswordMode="true" CssClass="sfregisterField sfregisterPassword" WrapperTag="li">
                <ValidatorDefinition MessageCssClass="sfError" Required="true"/>
            </sf:TextField>
            <sf:TextField ID="reTypePassword" runat="server" DisplayMode="Write" Title="<%$ Resources:UserProfilesResources, ReTypePassword %>" IsPasswordMode="true" CssClass="sfregisterField sfregisterConfirmPassword" WrapperTag="li">
                <ValidatorDefinition MessageCssClass="sfError">
                    <ComparingValidatorDefinitions>
                        <sfvalidation:ComparingValidatorDefinition ControlToCompare="password"
                            Operator="Equal" ValidationViolationMessage="<%$ Resources:ErrorMessages, CreateUserWizardDefaultConfirmPasswordCompareErrorMessage %>"/>
                    </ComparingValidatorDefinitions>
                </ValidatorDefinition>
            </sf:TextField>
        </ol>
        <asp:Panel ID="errorsPanel" runat="server" CssClass="sfErrorSummary" Visible="false"/>
        <div class="sfregisterLnkWrp">
            <asp:Button runat="server" ID="registerButton" Text="<%$ Resources:UserProfilesResources, Register %>" CssClass="sfregisterSaveLnk"/>
        </div>
    </asp:Panel>
    <asp:Label runat="server" ID="successMessageLabel"></asp:Label>
    <asp:Panel ID="configurationErrorsPanel" runat="server" CssClass="sfErrorSummary" Visible="false" >
        <div runat="server" id="smtpSettingsErrorWrapper" Visible="false">
            <asp:Label runat="server" id="smtpConfigurationErrorTitle" Text="<%$ Resources:ErrorMessages, CannotSendEmails %>"/>
            <asp:Label runat="server" id="smtpConfigurationError"></asp:Label>
        </div>
    </asp:Panel>
  
</fieldset>
1. The users registered from the form are automatically added to the database and appear under Administration ->Users

2. On click can not be added because you are inheriting from Sitefinity registration controls and the form executes the built in methods.

3. To use the sample code provided you must make a custom control. Follow the tutorial in the documentation. Make sure you add the build action of the .ascx file to EmbededResource. You may notice at the bottom of the code file"~/SfSamples/Telerik.Sitefinity.Samples1.Resources.RegistrationForm.ascx";
You should make the Layout Template path something like "~/Samples/ServerControl1.Resources.CustomLoginTemplate.ascx";
Notice the path ~/Samples this is the virtual path. You must register a virtual path to point to the .ascx file because it is an Embeded control now. To register go to Administration-> Settings -> Advanced -> Virtual Path Settings -> Virtual Paths and create new.
Fill in with:
VirtualPath    ~/Samples/*  --- put any name you like
ResourceLocation    ServerControl1    --- this is the name of your assemblie
ResolverName    EmbeddedResourceResolver

Then restart your project and you can use the control and extend it.

To add a custom field that will save its data in the database:
Create the custom field from sitefinity backend. Go to Administration->Users->Manage profile types. Edit the basic profile and add the field you require there. Note you don`t need to specify DB type because the control you use is inheriting from Sitefinity login control. After creating the custom field you will need its name in the .aspx template of the custom control.
<sf:TextField ID="CustomField1" runat="server" DataFieldName="CustomField1"DataItemType="Telerik.Sitefinity.Security.Model.SitefinityProfile" DisplayMode="Write"Title="<%$ Resources:Labels, FirstName %>" CssClass="sfregisterField sfregisterFirstName" WrapperTag="li" />

You may need to create a Label for the naming of the field.
This field will be saved in the database.


Kind regards,
Stanislav Velikov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 21-Feb-2012 00:00

Hi

Thank you very much  for your help but i am having problems with your instructions. I have been through the documentation you suggested. I can follow most of it, but the last step is confusing. The instructions to register the control seem to apply to web controls rather than server controls (the control is in a folder called user controls where as the instructions for server control has the control as a separate project) I have not built a server control before so if its possible to build a custom registration control as a web user control i would very much like to know! Also i am unsure about the use of virtual paths can you explain a little? finally can you explain what you mean by  "make sure you add the build action of the .ascx file to EmbeddedResource"

Thanks again, hope you can help again this time

Dan

Posted by Community Admin on 23-Feb-2012 00:00

Hi,

 It should be working as user control, but I haven`t tested this. The approach should be tha same, just everything will be in SitefinityWebApp project.
Here is a screenshot of how to change the build action : ( http://screencast.com/t/tt57jVO39 ).
The separate project generates a .dll file and to use the control reference the .dll file to SitefinityWebApp project and event if the other project is removed the .dll if present in the bin folder of Sitefinity project will be in use.

The virtual path:
~/SfSamples/Telerik.Sitefinity.Samples1.Resources.RegistrationForm.ascx"

~/SFSamples/ is the virtual path. You specify the name what suits you. 
Telerik.Sitefinity.Samples1 is the name of the new project created. It is also the name of the .dll file generated by this project (refered to as assembly name).

The remains of the path represent the folder structure. This is a sample folder structure ( screencast.com/.../3ecRUeZbc ).
A vurtual path here will be:

~/VirtualPathTest/SitefinityWebApp.Resources.WebUserControl1.ascx 

Regards,
Stanislav Velikov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 24-Feb-2012 00:00

Hi again

Thanks very much for your help. I have managed to register the server control in the toolbox using a virtual path and the layout is display with a custome field added. Sadly dispite using the exact code you suppiled it doesn't work, there is no action when the submit button is pressed and certainly no data is added to the database. Also the page is displayed correctly when previewed from the page open for editting, but when the page is published and then viewed i get the following error;

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: 'Telerik.Sitefinity.Samples1.Resources.RegistrationForm' is not a valid value for attribute 'tagname'.

Source Error:

Line 2:  <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
Line 3:  <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Modules.GenericContent.Web.UI" Assembly="Telerik.Sitefinity" %>
Line 4:  <%@ Register TagPrefix="sf" TagName="Telerik.Sitefinity.Samples1.Resources.RegistrationForm" Src="~/SfSamples1/Telerik.Sitefinity.Samples1.Resources.RegistrationForm.ascx" %>
Line 5:  <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web" Assembly="Telerik.Sitefinity" %>
Line 6:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/.../xhtml1-transitional.dtd">


I hope you can help once more, thanks

Dan

Posted by Community Admin on 24-Feb-2012 00:00

Hello,

 Cheking the error:

<%@ Register TagPrefix="sf" TagName="Telerik.Sitefinity.Samples1.Resources.RegistrationForm" Src="~/SfSamples1/Telerik.Sitefinity.Samples1.Resources.RegistrationForm.ascx" %>
make sure this full path is the same for the control on oyur end.
Is the project named: Telerik.Sitefinity.Samples1
Is RegistrationForm.ascx placed under folder called Resources?
Or the virtual path is different from ~/SfSamples1/?

All the best,
Stanislav Velikov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 24-Feb-2012 00:00

Hi

Virtual path is        ~/SfSamples1/*
Project name is     Telerik.Sitefinity.Samples1
and RegistrationForm.ascx is placed under a folder called Resources, i tried to dupilcate everything you did i can't see that i have missed anything.

Thanks again.

Posted by Community Admin on 15-May-2012 00:00

Hi Guys,

Did you ever get this problem resolved?
I followed the same directions and came up with the exact same error in the end.
I have gone through every step piece by piece and verified all the steps. I can see the control in the design view, but when I want to view the page normally I then get the error.

Any tips?

Thanks

Louis

Posted by Community Admin on 15-May-2012 00:00

Hi Guys,

Did you ever get this problem resolved?
I followed the same directions and came up with the exact same error in the end.
I have gone through every step piece by piece and verified all the steps. I can see the control in the design view, but when I want to view the page normally I then get the error.

Any tips?

Thanks

Louis

Posted by Community Admin on 16-May-2012 00:00

Hi Louis

Sadly i never got it to work even with detailed help from Stanislav.In the end i gave up and built custom registration user control from scratch, with asp.net validation tools and a bit of googling it was quite easy. Sorry i can't post the code, it became part of a commercial sitefinity site and i don't think my boss would like me posting it!
Maybe the custom registration widget if out of beta in release 5? or maybe this help;
www.sitefinity.com/.../events-registration-widget.aspx

sorry i can't be of more help.

Dan

Posted by Community Admin on 17-May-2012 00:00

Hi Guys,

For anyone who might be battling with the example in this thread. I have found the solution.The main changes I made was to in the .cs file implement the override for both LayoutTemplatePath and LayoutTemplateName. I also implemented the override for ResourcesAssemblyInfo.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.Sitefinity.Security.Web.UI;
 
namespace PLMCustomUserControls
    public class PLMUserRegisterControl : RegistrationForm
    
        protected override string LayoutTemplateName
        
            get
            
                return PLMUserRegisterControl.layoutTemplateName;
            
        
 
        public override string LayoutTemplatePath
        
            get
            
                return PLMUserRegisterControl.layoutTemplatePath;
            
        
 
        protected override Type ResourcesAssemblyInfo
        
            get
            
                return this.GetType();
            
        
 
        protected override void ConfirmRegistration(Telerik.Sitefinity.Security.UserManager userManager, Telerik.Sitefinity.Security.Model.User user)
        
            var userID = user.Id;
            //
            base.ConfirmRegistration(userManager, user);
        
 
        private const string layoutTemplatePath = "~/PLMCustom/PLMCustomUserControls.Resources.UserRegisterControl.ascx";
        private const string layoutTemplateName = "PLMCustomUserControls.Resources.UserRegisterControl.ascx";
    

Other than that the setup that was desribed is correct. Though I did change how the control was added into the toolbox. Instead of using the way suggested in the example. I instead into the control clr type or virtual path textbox entered this instead: PLMCustomUserControls.PLMUserRegisterControl, PLMCustomUserControls
In my project the first part before the comma is the path to my .cs file. Look at the code above I used namespace.classname.
This got my project up and running. I hope this helps someone.

Thanks

Louis

Posted by Community Admin on 10-Apr-2013 00:00

Hi,
I had the same problem and was getting that ugly error message.
I fixed it with a very simple solution:
1. Map external template. I used the following tutorial method 1
2. Add your custom field as follows:

<sf:TextField ID="CustomField1" runat="server" DataFieldName="CustomField1"DataItemType="Telerik.Sitefinity.Security.Model.SitefinityProfile" DisplayMode="Write"Title="<%$ Resources:Labels, FirstName %>" CssClass="sfregisterField sfregisterFirstName" WrapperTag="li" />


What I was missing is the DataItemType attribute to my custom fields, after adding it, it worked flawlessly.
3. If you need to edit the authentication method, use this method

Hope that Helped...
Ismail

Posted by Community Admin on 15-Apr-2013 00:00

Hello guys,

 Keep in mind that it's not absolutely necessary to create the custom registration form in a new project. You can also inherit from the default registration widget in a class file, placed in your SitefinityWebApp project. Then you will need to override the layoutTemplatePath property again to point to your custom template, but a relative path to the template will be enough. You won't have to add a tagPrefix, build the template as an embedded resource or register a VirtualPath.

All the best,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed