Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Custom Edit Profile (Registration Data) View modes: 
User avatar
Member
Member
Armysniper89 - 11/20/2010 1:52:38 PM
   
Custom Edit Profile (Registration Data)
I need to perform some additional code when a user edits their registration/profile data. Currently my site uses the My Account web part control with a custom layout and custom form. I thought I would simply clone it like the Custom Registration web part and add my code to the event handler for the"OK" button but there is no event handler! When I cloned the My Profile web part it showed only loading and reloading methods...so how can I customize this web part so I can add additional code that I need?

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 11/22/2010 5:42:35 AM
   
RE:Custom Edit Profile (Registration Data)
Hello,

The mentioned webpart is a bit different from other webparts as it uses various controls like the ~\CMSModules\Membership\Controls\MyProfile.ascx.cs control. You need to copy and reference those controls too, if you want to make a copy of the My Account webpart. I would suggest you to copy the files manually, to rename them and to create a new webpart with those files.

Best regards,
Boris Pocatko

User avatar
Member
Member
Armysniper89 - 11/22/2010 8:34:04 AM
   
RE:Custom Edit Profile (Registration Data)
I was afraid of that. Tell me this then, instead of doing this work in the control ,aye I can do it using the global event handler example? Would it trigger if I am editing a profile?

User avatar
Member
Member
Armysniper89 - 11/22/2010 10:52:19 AM
   
RE:Custom Edit Profile (Registration Data)
kentico_borisp wrote: Hello,

The mentioned webpart is a bit different from other webparts as it uses various controls like the ~\CMSModules\Membership\Controls\MyProfile.ascx.cs control. You need to copy and reference those controls too, if you want to make a copy of the My Account webpart. I would suggest you to copy the files manually, to rename them and to create a new webpart with those files.

Best regards,
Boris Pocatko


I would still prefer to do it in a control if it is not too painful, can you tell me where I can find the controls that are associated with the main web part? I am thinking the Global Event handler piece might be easier though... :)

User avatar
Member
Member
Armysniper89 - 11/28/2010 12:23:43 PM
   
RE:Custom Edit Profile (Registration Data)
So which way should I approach this. I cannot figure out how to get the MyProfile web parted cloned with its sub web parts to even customize it! Also, can I get a "User Edited Profile" event to happen in the Global Event Handler? Some assistance please.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 11/29/2010 3:56:38 AM
   
RE:Custom Edit Profile (Registration Data)
Hello,

I tried to make a copy of the mentioned webpart by copying manually the following files:

\CMSWebParts\Membership\Profile\MyProfile.ascx(.cs)
\CMSModules\Membership\Controls\MyProfile.ascx(.cs)

and updated the references in the ascx files where it was necessary (e.g. to the copy of the files):


<%@ Control Language="C#" AutoEventWireup="true" CodeFile="~/CMSWebParts/Membership/Profile/MyProfile2.ascx.cs" Inherits="CMSWebParts_Membership_Profile_MyProfile2" %>
<%@ Register Src="~/CMSModules/Membership/Controls/MyProfile2.ascx" TagName="MyProfile2" TagPrefix="cms" %>

<asp:Label ID="lblError" CssClass="ErrorLabel" runat="server" Visible="false" EnableViewState="false" />
<asp:PlaceHolder id="plcContent" runat="server">
<cms:MyProfile2 ID="myProfile" runat="server" />
</asp:PlaceHolder>



After I registered the webpart in CMS Site Manager I was able to place it on the page without problems.

You can create a new event according to some guide on the net as this approach is the same on every .NET application. You can trigger the event from the "editProfileForm_OnBeforeSave()" method in the MyProfile.ascx.cs file in the Controls folder which is called after the "OK" button is clicked.

Best regards,
Boris Pocatko

User avatar
Member
Member
Armysniper89 - 11/29/2010 11:07:42 AM
   
RE:Custom Edit Profile (Registration Data)
I can make a clone of the control with no problems, but what I was looking for is a handler for the web part's "OK" button, which is not there but somewhere out there. I figured that would be the easiest approach since the code I have to write is already working in a clone of the "Custom Registration" web part in its "Register" button event handler.

Your previous messages recommended cloning the web parts that are part of the My Profile web part but I dont know where to find them.


User avatar
Member
Member
Armysniper89 - 11/29/2010 11:33:02 AM
   
RE:Custom Edit Profile (Registration Data)
kentico_borisp wrote: Hello,
You can create a new event according to some guide on the net as this approach is the same on every .NET application. You can trigger the event from the "editProfileForm_OnBeforeSave()" method in the MyProfile.ascx.cs file in the Controls folder which is called after the "OK" button is clicked.


There is no "OnBeforeSave" method in the code that I have for the cloned web part...only OnContentLoaded SetupControl and ReloadData. Can I simply create an override for this? What would the override look like?

User avatar
Member
Member
Jeffrey H. - 11/29/2010 1:47:16 PM
   
RE:Custom Edit Profile (Registration Data)
I think that you need to make a copy of the user control at /CMSModules/Membership/Controls/MyProfile.ascx, then add your OnBeforeSave event handler to the DataForm control.

Finally, make a clone of the actual webpart, then change the registration of the MyProfile.ascx usercontrol to the one you copied and added your event handler to.

Sometimes the webparts interact verly closely with other controls inside modules and it can get confusing, but I think that this will work for your situation.

Regards,

Jeffrey

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 11/30/2010 11:13:40 AM
   
RE:Custom Edit Profile (Registration Data)
Hello,

You need to make a physical copy of the files. Cloning them through the user interface won't create all the necessary files and methods. If you make an exact copy, all the necessary methods will be available.

Best reagrds,
Boris Pocatko

User avatar
Member
Member
Armysniper89 - 12/6/2010 1:33:35 PM
   
RE:Custom Edit Profile (Registration Data)
OK I got this working but let me summarize for the future readers who might find this:

1. Created a copy of the module control, ~/CMSModules/Membership/Controls/MyProfile.ascx. Added my changes to the "Before Save" event handler.
2. Created a clone in SiteManager for the Edit Account web part.
3. Changed the wiring of the web part in the ASCX file to use the copied MyProfile Module control.
4. Added the cloned web part and away I go.


Thanks to all for their help on this. Helped me get a better understanding of the product as well as get this feature working.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 12/7/2010 9:29:00 AM
   
RE:Custom Edit Profile (Registration Data)
Hello,

Great summarization. I am sorry, if I was not specific enough in my answers. I am glad it is working for you now.

Best regards,
Boris Pocatko

User avatar
Member
Member
Imran - 6/20/2011 5:29:37 PM
   
RE:Custom Edit Profile (Registration Data)
Can we add our own button in my profile, as compared to the default ok button?

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 7/4/2011 5:50:25 AM
   
RE:Custom Edit Profile (Registration Data)
Hello,

Of course. However this will require some workarounds. You would have to create a custom "OK" button which would call the default "OK" button on the click of your custom one. You can hide the default button with CSS styles.

Best regards,
Boris Pocatko