MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Custom Database fields.  (Mono Support )

Viewed 65026 time(s), 19 post(s) 5/16/2011 3:45:20 PMby shawndg
shawndg

shawndg

5/16/2011 3:45:20 PM
Hello Guys,

Im back! haha .. well been occupied doing some other things but back to Monox..

Now, im working on extended the registration section.. I read a couple post on the forums, as well as found one in the MonoX installed forum but Im still a little lost..

Now, I am trying to create a custom web part that I can put on a web page and point users to that page to allow them to sign up for the website.. Now my problem is the default signup process for Monox is simply not enough to satisfy the input needs of my site.

I think im close, I created my own version of the web control by inheriting the original.. but I seem to be having some problems with converting the original page into a actual web part.

Here is a copy of my code..

<%@ Control Language="C#" AutoEventWireup="true" Inherits="TheScene.Web.CusBandRegister.MembershipEditor" Codebehind="MembershipEditor.aspx.cs" %>
<%@ 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>
        <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"></MonoX:StyledButton>
            <MonoX:StyledButton ID="btnUpdateAccount" runat="server" CssClass="CssFormButton"></MonoX:StyledButton>
        </div>
    </div>
</div>   
</div>


Just was trying some examples i found on the forum to see if it is working.. have not got into the database storing just yet but that part should not be to complicated however I was wondering about canceling the save if a field is invalid.. and outputting a msg to the ui..

any ways here the code part..
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 TheScene.Web.BandRegister
{
    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;
        }
 
        protected override void OnInit(EventArgs e)
        {
            base.AccountCreationCompleted += new EventHandler(ctlMembership_AccountCreationCompleted);
            base.OnInit(e);
        }
 
 
        void ctlMembership_AccountCreationCompleted(object sender, EventArgs e)
        {
            int a = 456;
        }
 
 
    }
}

If anything comes to mind that is wrong in my code please let me know.. because its not working at the moment.
This content has not been rated yet. 
1871 Reputation 252 Total posts
khorvat

khorvat

5/17/2011 7:09:06 AM
Hi,

can you send us the exact error message that you get while compiling ?

Just to mention a common mistake while inheriting Web parts is that Visual Studio generates the designer file with all the controls inside the mark-up (MonoX controls and controls added by you). As the Web part that you are inheriting is basically a UserControl (a compiled one), this Web part already has all these mark-up controls declared and your designer file is interfering with the MonoX one. As a result your are getting runtime exception - System.NullReferenceException - Object reference not set to an instance of an object, if this is your scenario you can fix this by removing all the MonoX (built-in) controls from your designer file.

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts
shawndg

shawndg

5/17/2011 9:43:40 PM
Ok..

Revisited the code..

Here is update on the code..

MembershipEditor.ascx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MonoSoftware.MonoX;
using MonoSoftware.MonoX.Utilities;
 
using MonoSoftware.MonoX.ModuleGallery;
 
namespace TheScene.Web.WebParts
{
    public partial class MembershipEditor : MonoSoftware.MonoX.ModuleGallery.MembershipEditor
    {
     
        void MembershipEditor_AccountCreating(object sender, MembershipModuleEventArgs e)
        {
            int a = 456;
        }
        void MembershipEditor_AccountCreated(object sender, MembershipModuleEventArgs e)
        {
            int a = 456;
        }
 
        protected override void OnInit(EventArgs e)
        {
            base.AccountCreationCompleted += new EventHandler(ctlMembership_AccountCreationCompleted);
            base.OnInit(e);
        }
 
 
        void ctlMembership_AccountCreationCompleted(object sender, EventArgs e)
        {
            int a = 456;
        }
 
 
    }
}
MarkUp
<%@ Control Language="C#" AutoEventWireup="true" Inherits="TheScene.Web.CusBandRegister.MembershipEditor" Codebehind="MembershipEditor.ascx.cs" %>
<%@ 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>
        <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"></MonoX:StyledButton>
            <MonoX:StyledButton ID="btnUpdateAccount" runat="server" CssClass="CssFormButton"></MonoX:StyledButton>
        </div>
    </div>
</div>   
</div>

Created a test, local static web control..
MembershipEditor.aspx
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
 
namespace TheScene.Web
{
    public partial class BandRegister : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
 
        }
 
         
    }
}
MarkUp
<%@ Page Language="C#" MasterPageFile="/MonoX/MasterPages/Default.master" AutoEventWireup="true" Inherits="TheScene.Web.BandRegister" Title="Web part sample" Theme="Default" Codebehind="MembershipEditor.aspx.cs" %>
<%@ MasterType TypeName="MonoSoftware.MonoX.BaseMasterPage" %>
 
<%@ Register TagPrefix="BandRegistration" TagName="BandRegistration" Src="/TheScene/WebParts/BandRegister/MembershipEditor.ascx" %>
 
<%@ Register Assembly="MonoX" Namespace="MonoSoftware.MonoX" TagPrefix="portal" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cp" Runat="Server">
    <table width="998" border="0" align="center" cellspacing="0" cellpadding="0">
      <tr>
        <td width="239" valign="top" class="toppadding10px">
            <portal:PortalWebPartZone HeaderText="Left part zone" ID="leftWebPartZone" runat="server" Width="100%" ChromeTemplateFile="LeftColumn.htm" ShowChromeForNonAdmins="true">
                <ZoneTemplate>
 
                    <BandRegistration:BandRegistration runat="server" ID="BandRegistrationPlace0" Title="Band Registration" />
 
                </ZoneTemplate>
 
            </portal:PortalWebPartZone>
        </td>
 
      </tr>
    </table>
</asp:Content>


Error..


Server Error in '/TheScene' Application.


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:
'TheScene.Web.CusBandRegister.MembershipEditor' is not allowed here because
it does not extend class 'System.Web.UI.UserControl'.

Source
Error:

Line 1: <%@ Control Language="C#" AutoEventWireup="true" Inherits="TheScene.Web.CusBandRegister.MembershipEditor" Codebehind="MembershipEditor.ascx.cs" %>
Line 2: <%@ Register TagPrefix="MonoX" TagName="StyledButton" Src="/MonoX/controls/StyledButton.ascx" %>
Line 3:
Source File:
/TheScene/TheScene/WebParts/BandRegister/MembershipEditor.ascx Line:
1

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET
Version:4.0.30319.1
This content has not been rated yet. 
1871 Reputation 252 Total posts
shawndg

shawndg

5/17/2011 9:45:41 PM
I am also getting a lot of errors.. -
Error 4 The name 'DefaultResources' does not exist in the current context c:\#TheScene\TheScene\WebParts\BandRegister\MembershipEditor.ascx 40 102 Portal
This content has not been rated yet. 
1871 Reputation 252 Total posts
shawndg

shawndg

5/17/2011 11:10:43 PM
Ok, well I got it working sorta..

Here is my code so far..

MembershipEditor.ascx.cs
using System;
using MonoSoftware.MonoX.ModuleGallery;
 
namespace TheScene.Web.WebParts
{
        public partial class RegisterBands : MonoSoftware.MonoX.ModuleGallery.MembershipEditor
        {
 
            void MembershipEditor_AccountCreating(object sender, MembershipModuleEventArgs e)
            {
                int a = 456;
            }
            void MembershipEditor_AccountCreated(object sender, MembershipModuleEventArgs e)
            {
                int a = 456;
            }
 
            protected override void OnInit(EventArgs e)
            {
                base.AccountCreationCompleted += new EventHandler(ctlMembership_AccountCreationCompleted);
                base.OnInit(e);
            }
 
 
            void ctlMembership_AccountCreationCompleted(object sender, EventArgs e)
            {
                int a = 456;
            }
 
        }
 }
MarkUp.
<%@ Control Language="C#" AutoEventWireup="true" Inherits="TheScene.Web.WebParts.RegisterBands" Codebehind="MembershipEditor.ascx.cs" %>
<%@ 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>
        <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"></MonoX:StyledButton>
            <MonoX:StyledButton ID="btnUpdateAccount" runat="server" CssClass="CssFormButton"></MonoX:StyledButton>
        </div>
    </div>
</div>   
</div>

Notice that I remed out all the Default Resource.. Im not sure why I needed to do this but it has to do with the language file I think..

any ideas to fix it the right way vs hand typed values ?

I also still need to figure out how to check my own fields for validation, like the password field does to check the length etc..
any idea how I can do this ? output a error msg and stop the control from processing / creating the account ?

This content has not been rated yet. 
1871 Reputation 252 Total posts
shawndg

shawndg

5/17/2011 11:12:09 PM
Ohh ops.. forgot..

I also fixed a bug in the MembershipEditor.aspx test file.. figured I would post that incase someone is using my code as ref..

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
 
namespace TheScene.Web
{
    public partial class BandRegister : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
 
        }
 
         
    }
}

MarkUp.
<%@ Page Language="C#" MasterPageFile="/MonoX/MasterPages/Default.master" AutoEventWireup="true" Inherits="TheScene.Web.BandRegister" Title="Web part sample" Theme="Default" Codebehind="MembershipEditor.aspx.cs" %>
<%@ MasterType TypeName="MonoSoftware.MonoX.BaseMasterPage" %>
 
<%@ Register TagPrefix="BandRegistration" TagName="BandRegistration" Src="/TheScene/WebParts/BandRegister/MembershipEditor.ascx" %>
 
<%@ Register Assembly="MonoX" Namespace="MonoSoftware.MonoX" TagPrefix="portal" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cp" Runat="Server">
    <table width="998" border="0" align="center" cellspacing="0" cellpadding="0">
      <tr>
        <td width="239" valign="top" class="toppadding10px">
            <portal:PortalWebPartZone HeaderText="Left part zone" ID="leftWebPartZone" runat="server" Width="100%" ChromeTemplateFile="LeftColumn.htm" ShowChromeForNonAdmins="true">
                <ZoneTemplate>
 
                    <BandRegistration:BandRegistration runat="server" ID="BandRegistrationPlace0" Title="Band Registration" />
 
                </ZoneTemplate>
 
            </portal:PortalWebPartZone>
        </td>
 
      </tr>
    </table>
</asp:Content>
This content has not been rated yet. 
1871 Reputation 252 Total posts
khorvat

khorvat

5/18/2011 7:03:42 AM
Hi,

as I can see you have fixed most of your issues, to get the resource files to load (e.g. DefaultResources.MembershipEditor_RememberMe) you need to add the following line to your mark-up

<%@ Import Namespace="MonoSoftware.MonoX.Resources"%>

This will import the resource namespace to the mark-up and allow you to use the MonoX resources.

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts
shawndg

shawndg

5/23/2011 11:30:46 PM
Ok.. now I am having a problem..

I am working on trying to validate input..

My own, as well as allow for profiles to be created with space..

I cant get my own verification function to work or stop the execution of the built in monox control upon a custom error.
I cant figure out how to allow me to allow usernames to include '-'

Below is a example..

using System;
using MonoSoftware.MonoX.ModuleGallery;
 
namespace TheScene.Web.WebParts
{
    public partial class RegisterBands : MonoSoftware.MonoX.ModuleGallery.MembershipEditor
    {
 
        void MembershipEditor_AccountCreating(object sender, MembershipModuleEventArgs e)
        {
            int a = 456;
 
            //automatic format nice band name
            this.UserName = this.UserName.Replace(" ", "-");
 
            if (this.UserName.Length >= 3)
            {
                this.ErrorMsg.Text = "Invalid Band Name";
                //abort account creation ?
            }
 
                 
            
        }
 
        void MembershipEditor_AccountCreated(object sender, MembershipModuleEventArgs e)
        {
            int a = 456;
        }
 
        protected override void OnInit(EventArgs e)
        {
            base.AccountCreationCompleted += new EventHandler(ctlMembership_AccountCreationCompleted);
            base.OnInit(e);
        }
 
 
        void ctlMembership_AccountCreationCompleted(object sender, EventArgs e)
        {
            int a = 456;
        }
 
    }
}
This content has not been rated yet. 
1871 Reputation 252 Total posts
khorvat

khorvat

5/24/2011 7:47:45 AM
Hi,

you can do two things to overcome the issue you are facing:

1. Don't allow spaces in the username but allow the slash (This should be handled on the client side - convert all spaces to slashes)
2. Try to disable the below custom validator and enforce your own validation as you have described
<asp:CustomValidator ID="vldCustomUserName" runat="server" ControlToValidate="txtUserName" Text="!" SetFocusOnError="true" CssClass="validator ValidatorAdapter" Display="Dynamic" />

I hope this helps you solve the problem, get back to us if you need more information.

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts
shawndg

shawndg

6/3/2011 2:40:54 PM
Ok..

I cant get my custom form validation to work ?

I edited my markup..

added..

<asp:CustomValidator ID="vldCustomUserName" runat="server" ControlToValidate="txtUserName" OnServerValidate="BandNameValidate" ErrorMessage="Invalid Band Name" Text="!" SetFocusOnError="true" CssClass="validator ValidatorAdapter" Display="Dynamic" />

then I edited the code behind it...

protected void BandNameValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = (args.Value.Length > 2);
}

at first it said ServerValidateEventArgs namespace not found.. so then i added..
using System.Web.UI.WebControls; to the top..

the error went away.. but monox completely ignored my error check..

Now.. I also am trying to remove all spaces from name when you first submit it..
i got rid of the dash idea in favor of long names.. Example "the Name" .. auto change to "theName"

But I also have a need for custom field validation.. server side.. and I need the ability to tell monox.. to create or not create the profile base on the input they provide and the checks I perform.

Any idea what is going on or how to fix this ?
This content has not been rated yet. 
1871 Reputation 252 Total posts
1 2