Mono Support using MonoX built in modules 

Viewed 84997 time(s), 18 post(s), 1/6/2011 9:12:02 AM - by inanc
1/8/2011 10:33:09 PM
7207 Reputation 956 Total posts

I just pasted the TestProfile.aspx code to the fresh MonoX 4 install and sample project in Visual Studio 2010. Works without any problems.
I just did the same for another user on this forum, and it appears to be a fundamental glitch - you've must been using the sample project in a wrong way. To quickly diagnose what's going on, please zip the custom solution files without any changes and send it to our support address. We will restore your solution over the original install and try to debug it.

11
1/10/2011 1:18:14 PM
469 Reputation 60 Total posts

Hello Denis,
Thank you very much for your interest. I've installaed your new version and tried the code again. I have no problem right now. Thank you again.

12
2/14/2011 9:52:53 PM
469 Reputation 60 Total posts

I would like to ask one more thing about MembershipEditor_AccountCreating event.
Let us assume that we want two additional profile fields stored another profile related table. Let's call them as HairColor and EyeColor. In the MemberShipEditor module I've added these two extra fields.
aspx part;

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MembershipEditor.ascx.cs" Inherits="ProjectName.Web.prDene.WebParts.MembershipEditor" %>
<%@ Import Namespace="MonoSoftware.MonoX.Resources"%>
<%@ Register TagPrefix="MonoX" TagName="StyledButton" Src="/MonoX/controls/StyledButton.ascx" %>
  
<div class="membership-module-container input-form" style="">
<div id="Div1" runat="server">
    <asp:ValidationSummary ID="validationSummary" CssClass="validation-summary" runat="server" />
</div>  
<div class="register">
    <h2><%= Page.User.Identity.IsAuthenticated ? DefaultResources.MembershipEditor_Title_UpdateAccount : DefaultResources.MembershipEditor_Title_CreateAccount %></h2>
    <dl>
        <dd>
            <label for="<%= txtUserName.ClientID %>"><%= DefaultResources.MembershipEditor_UserName %></label>
            <asp:Label ID="lblUserName" runat="server"></asp:Label>
            <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="vldRequiredUserName" runat="server" ControlToValidate="txtUserName" Text="!" SetFocusOnError="true" CssClass="validator ValidatorAdapter" Display="Dynamic" />
            <asp:CustomValidator ID="vldCustomUserName" runat="server" ControlToValidate="txtUserName" Text="!" SetFocusOnError="true" CssClass="validator ValidatorAdapter" Display="Dynamic" />
        </dd>
        <dd>
            <label for="<%= txtPassword.ClientID %>"><%= DefaultResources.MembershipEditor_Password %></label>
            <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
            <asp:RequiredFieldValidator ID="vldRequiredPassword" runat="server" ControlToValidate="txtPassword" Text="!" SetFocusOnError="true" CssClass="validator ValidatorAdapter" Display="Dynamic" />
        </dd>
        <dd>
            <label for="<%= txtRepeatPassword.ClientID %>"><%= DefaultResources.MembershipEditor_RepeatPassword %></label>
            <asp:TextBox ID="txtRepeatPassword" runat="server" TextMode="Password"></asp:TextBox>
            <asp:RequiredFieldValidator ID="vldRequiredRepeatPassword" runat="server" ControlToValidate="txtRepeatPassword" Text="!" SetFocusOnError="true" CssClass="validator ValidatorAdapter" Display="Dynamic" />
            <asp:CompareValidator ID="vldCompareRepeatPassword" runat="server" ControlToValidate="txtRepeatPassword" Text="!" SetFocusOnError="true" ControlToCompare="txtPassword" Operator="Equal" CssClass="validator ValidatorAdapter" Display="Dynamic"></asp:CompareValidator>
        </dd>
        <dd>
            <label for="<%= txtEmail.ClientID %>"><%= DefaultResources.MembershipEditor_Email %></label>
            <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="vldRequiredEmail" runat="server" ControlToValidate="txtEmail" Text="!" SetFocusOnError="true" CssClass="validator ValidatorAdapter" Display="Dynamic" />
            <asp:RegularExpressionValidator ID="vldRegexEmail" runat="server" ControlToValidate="txtEmail" Text="!" SetFocusOnError="true" CssClass="validator ValidatorAdapter" Display="Dynamic" />
        </dd>
        <dd>
            <label>Hair Color</label>
            <asp:TextBox ID="txtHairColor" runat="server"></asp:TextBox>
        </dd>
        <dd>
            <label>Eye Color</label>
            <asp:TextBox ID="txtEyeColor" runat="server"></asp:TextBox>
        </dd>
        <asp:PlaceHolder ID="plhRememberMe" runat="server">
            <dd>
                <label> </label>
                <asp:CheckBox ID="chkRememberMe" runat="server" style="float: left;" />
                <label style="margin-top: 2px; float: left;" for="<%= chkRememberMe.ClientID %>"><%= DefaultResources.MembershipEditor_RememberMe %></label>                
            </dd>
        </asp:PlaceHolder>
        <dd>
            <asp:Label ID="labInfo" runat="server"></asp:Label>
        </dd>
    </dl>
    <div class="input-form">
        <div class="button-holder" style="float: right;">
            <MonoX:StyledButton ID="btnCreateAccount" runat="server" CssClass="CssFormButton" Text="Create"></MonoX:StyledButton>
            <MonoX:StyledButton ID="btnUpdateAccount" runat="server" CssClass="CssFormButton" Text="Update" Visible="false"></MonoX:StyledButton>
        </div>
    </div>
</div>    
</div>


and the codebehind file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MonoSoftware.MonoX;
using MonoSoftware.MonoX.ModuleGallery;
  
namespace ProjectName.Web.prDene.WebParts
{
    public partial class MembershipEditor :MonoSoftware.MonoX.ModuleGallery.MembershipEditor
    {
        protected void Page_Load(object sender, EventArgs e)
        {
  
        }
        void MembershipEditor_AccountCreating(object sender, MembershipModuleEventArgs e)
        {
            int a = 456;
        }
        void MembershipEditor_AccountCreated(object sender, MembershipModuleEventArgs e)
        {
            int a = 456;
        }
    }
}

According to the note given on this forum, I've made my class inherited from "MonoSoftware.MonoX.ModuleGallery.MembershipEditor". But the problem is I can't the break the code while running on 'int a = 456;' lines.
How could I catch these special events in order to insert the additional profile felds to related tables. Thank you.
Inanc

13
2/14/2011 9:54:03 PM
15993 Reputation 2214 Total posts

Hi Inanc,

to catch these events you need to attach to them like this:

protected override void OnInit(EventArgs e)
{
   base.OnInit(e);
   base.AccountCreationCompleted += new EventHandler(ctlMembership_AccountCreationCompleted);
}
  
void ctlMembership_AccountCreationCompleted(object sender, EventArgs e)
{
  int a = 456;
}

Let us know if you need anything else.

Regards

14
2/14/2011 9:54:48 PM
469 Reputation 60 Total posts

Dear Kristijan

The code given below doesn't catch the ctlMembership_AccountCreationCompleted evant. Do u have any idea? Thank you.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MonoSoftware.MonoX;
using MonoSoftware.MonoX.ModuleGallery;
  
namespace ProjectName.Web.prDene.WebParts
{
    public partial class MembershipEditor :MonoSoftware.MonoX.ModuleGallery.MembershipEditor
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            base.AccountCreationCompleted += new EventHandler(ctlMembership_AccountCreationCompleted);
        }
  
        protected void Page_Load(object sender, EventArgs e)
        {
               
        }
  
        void ctlMembership_AccountCreationCompleted(object sender, EventArgs e)
        {
            int a = 456;
            txtEyeColor.Text = "tosbaga";
        }
  
    }
}

15
2/14/2011 9:55:33 PM
469 Reputation 60 Total posts

Ok.I found the error on OnInit. It should be :

protected override void OnInit(EventArgs e) 
base.AccountCreationCompleted += new EventHandler(ctlMembership_AccountCreationCompleted); 
base.OnInit(e); 

Custom event should be added before initializing.Thanks.

16
1/12/2011 10:12:42 AM
469 Reputation 60 Total posts

When I use the custom modules inherited for originals localization doesn’t work right. It writes First Name instead of ‘Ad’ on UserProfile section for example. ‘Ad’ means First Name in Turkish. But when using your original modules everything seem right. Do you have any idea?
Thank you

17
1/12/2011 1:37:59 PM
7207 Reputation 956 Total posts

Please send the complete code to our support address (both ascx and ascx.cs files).

18
1 2
This is a demo site for MonoX. Please visit Mono Software for more info.