Registration widget problem
Hi 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.
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".
Any advice on this greatly appreciated.
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"
;
<%@ 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>
"~/SfSamples/Telerik.Sitefinity.Samples1.Resources.RegistrationForm.ascx"
;
<
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" />
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
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
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
Hello,
Cheking the error:
<%@ Register TagPrefix="sf" TagName="Telerik.Sitefinity.Samples1.Resources.RegistrationForm" Src="~/SfSamples1/Telerik.Sitefinity.Samples1.Resources.RegistrationForm.ascx" %>
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.
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
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
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
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"
;
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" />
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,