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 98539 time(s), 19 post(s) 5/16/2011 3:45:20 PMby shawndg

Related topics

shawndg

shawndg

6/3/2011 2:53:06 PM
tried another thing..

changed code behind too..

protected void BandNameValidate(object source, EventArgs arg)
{
this.vldCustomUserName.IsValid = false;
}

remove using ref..

still no go..
This content has not been rated yet. 
1871 Reputation 252 Total posts
khorvat

khorvat

6/4/2011 8:25:51 AM
Hi,

to add your own custom validation don't use the existing (MonoX built-in) validator called "vldCustomUserName" but add your own. At the moment MonoX has below server side validation attached to the mentioned validator that's why it isn't working. 

void vldCustomUserName_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
    //no spaces and filesystem illegal characters are allowed in the username
    args.IsValid = args.Value.IndexOf(" ") == -1 && args.Value.IndexOfAny(System.IO.Path.GetInvalidPathChars()) == -1 && args.Value.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) == -1;
}

Please add the CustomValidator of your own and use args.IsValid to tell if the form is valid.

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

shawndg

6/26/2011 12:18:37 AM
Ok..

I got it sorta working..

now I am having some new issues..

I could not remove the custom validation.. if I did i got some odd error..
so instead I set it to disabled.. I was now able to get past that issue with spaces and invalid characters.

The new problem now is.. I am unable to stop MonoX using my own validator..
I added my own custom server side validation and when i try to set it to .isvalid = false// MonoX ignores it completely..
page still process and MonoX creates a user.. my validations are ignored.

Second..
I am working on building my own ext database info off of MonoX...
In order to do so I need MonoX to tell me what ID it just created and allow me a chance to insert my ext info into my own table..
Now I successfully implemented A Linqs system to handle my data and everything is working except..
I dont know how to grab the UserID GUID that MonoX just created during the user creation..
I need this to create my link so that I can join my ext table with MonoX to pull all the information
This content has not been rated yet. 
1871 Reputation 252 Total posts
shawndg

shawndg

6/26/2011 5:57:25 AM
Ok..

I want to add..

I got all the database stuff figured out.. Initial creation, and the edit page..
Now the only major issue is the inability to stop Monox from processing using the Isvalid args..

For any one needed some insight on profile saving and updating here it is..

saving.. example..
public override void CreateAccount(MembershipUser membershipUser)
  {
 
      Guid userId = SecurityUtility.GetUserId(membershipUser.UserName);         
       
       //add your database code here .. i used this method as way to pull the guid that stored
          //in the database that is
neededfor any type of database logic linking.
 
  }



updating..
this caused me some headache.. to get around it.. and figure out that monox has its own event handler

protected override void OnInit(EventArgs e)
{
    base.AccountUpdated += new MembershipModuleEvent(ctlMembership_AccountUpdated);
    base.OnInit(e);
}

     void ctlMembership_AccountUpdated(object sender, MembershipModuleEventArgs e)   
     {
 
         //get active Monox User Id
         Guid userId = SecurityUtility.GetUserId();
 
// add your database code here
 
     }

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

khorvat

6/26/2011 7:33:17 AM
Hi,

  can you please take a look at the ValidationGroup of the WebPart, you need to be sure that ValidationGroup is the same.

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

shawndg

6/27/2011 2:28:11 AM
The ValidationGroup on all of the validators have no value ?

not sure what you mean by ValidationGroup of the web part.

Here is a copy of the webpart base code.

<%@ Control Language="C#" AutoEventWireup="true" Inherits="TheScene.Web.WebParts.RegisterBands" Codebehind="MembershipEditor.ascx.cs" %>
<%@ Register TagPrefix="MonoX" TagName="StyledButton" Src="/MonoX/controls/StyledButton.ascx" %>
<%@ Import Namespace="MonoSoftware.MonoX.Resources"%>
  
<div class="membership-module-container input-form" style="">
<div id="Div1" runat="server">
    <asp:ValidationSummary ID="validationSummary" CssClass="validation-summary" runat="server" />
    <asp:Label ID="ErrorMsg" runat="server" ForeColor="Red"></asp:Label>
</div>
  
<div class="register">
    <h2>
        <%= Page.User.Identity.IsAuthenticated ? DefaultResources.MembershipEditor_Title_UpdateAccount : DefaultResources.MembershipEditor_Title_CreateAccount %>
    </h2>
    <dl>
 
        <dd>
            <asp:Label ID="lblUserName" runat="server"></asp:Label>
            <asp:Label ID="lblUrlBandName" runat="server" Text="UrlBand"
                meta:resourcekey="BandUrl"></asp:Label>
            <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
        </dd>
 
        <dd>
            <asp:Label ID="lblBandName" runat="server" Text="BandName"
                meta:resourcekey="BandName"></asp:Label>
            <asp:TextBox ID="txtBandName" runat="server"></asp:TextBox>
   
            <asp:RequiredFieldValidator ID="vldRequiredUserName" runat="server"
                ControlToValidate="txtUserName" Text="!" SetFocusOnError="true"
                CssClass="validator ValidatorAdapter" Display="Dynamic"
                EnableClientScript="False" Enabled="False" />
 
            <asp:CustomValidator ID="vldCustomUserName" runat="server"
                ControlToValidate="txtUserName" ErrorMessage="Invalid Band Name" Text="!" SetFocusOnError="true"
                CssClass="validator ValidatorAdapter" Display="Dynamic" Enabled="False" />
 
                <asp:CustomValidator ID="vldBandName" runat="server"
                ControlToValidate="txtUserName" OnServerValidate="BandNameValidate"
                ErrorMessage="Invalid Band Name" Text="!" SetFocusOnError="true"
                CssClass="validator ValidatorAdapter" Display="Dynamic" />
        </dd>
 
 
        <dd>
            <asp:Label ID="lblGenre" runat="server" Text="Genre" meta:resourcekey="Genre"></asp:Label>
            <asp:DropDownList ID="DropGenre" runat="server"></asp:DropDownList>
        </dd>
     
 
        <dd>
            <asp:Label ID="lblFaceBook" runat="server" Text="FaceBook"
                meta:resourcekey="FaceBook"></asp:Label>
            <asp:Textbox ID="txtFaceBook" runat="server"></asp:Textbox>
        </dd>
     
        <dd>
            <asp:Label ID="lblTwitter" runat="server" Text="Twitter"
                meta:resourcekey="Twitter"></asp:Label>
            <asp:Textbox ID="txtTwitter" runat="server"></asp:Textbox>
        </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>


Any idea whats wrong ??
This content has not been rated yet. 
1871 Reputation 252 Total posts
khorvat

khorvat

6/27/2011 10:53:56 AM
Hi,

mark-up looks ok to me, can you please post the code behind so we can take a look at the BandNameValidate implementation.

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

shawndg

6/27/2011 3:53:22 PM
its this simple..


protected void BandNameValidate(object source, ServerValidateEventArgs args)
{
txtUserName.Text = txtUserName.Text.Replace(" ", "");
args.IsValid = false; //should invalidate the form but it does not..
}

Im just trying to invalidate evrything at the moment just to make sure the isvalid is stopping monox..
This content has not been rated yet. 
1871 Reputation 252 Total posts
khorvat

khorvat

6/28/2011 8:37:15 AM
Hi,

I have reproduced the issue you are having, and you did everything ok except the validation group that I have mentioned. As you have inherited from MonoSoftware.MonoX.ModuleGallery.MembershipEditor which is a MonoX WebPart it has dinamically generated validation group value (It has to be dinamically generated because user can add more than one Membership editor to the Web part zone - Page, and every membership editor has to operate in a separate validation group). So this is the code you have to add to your Membership editor

protected override void OnPreRender(EventArgs e)
{
    base.OnPreRender(e);
    vldBandName.ValidationGroup = this.ValidationGroup;
}


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