Username Field Disable

Hi Chris,
I would like to disable the username on UI as the Administrator will assign the username at approving ,can I know apart from removing the code from create User.aspx where else should I remove the username code.

Thanks

Do you mean in the membership request web part? Unfortunately the username requirement is pretty baked into the existing code as well as the Microsoft control that it augments. I think it would be very difficult to allow them to submit without the username. You could potentially automatically set the username to their email address or something like that, but there’s not much to support having the username set at a later time. If you really wanted to do that you’d probably be better creating your own form (Maybe even just a sharepoint list set to allow anonymous users, and user’s requesting access can enter their details), and then the administrator could create the users himself on the user management page.

1 Like

Hi Chris,Yes it’s under memebership request we part,I mean the user name should detect the email automatically rather displaying as a username in the request form…

Can I know How can it be done automatically to set the username to their email address ?

It would be much appreciate if you could able to let me know where should i mainly amend the code in membershiprequesterbpart.cs .

Also can I know is it possible to write a workflow to copy and save the item in a other location from membership review list before approving ? As I want to store the data because I have added some custom fields like Role ,Organisation and contact number these fields are not copied over to fbauser management after
Approved.
Thanks for your help.

Hi Chris,

I would like to change the UserName to UserEmail on the front end of Membership request webpart on createUserSteptemplate,aspx.

can I know how this can be done without amending the code ,I have tried just changing the <asp:TextBox ID=“UserEmail” runat=“server”></asp:TextBox> but its not working I am getting the below message

Sorry, something went wrong

An unexpected error has occurred.

Web Parts Maintenance Page: If you have permission, you can use this page to temporarily close Web Parts or remove personal settings. For more information, contact your site administrator.

Technical Details


You can’t really change the username field to the email address field - the control always expects the username field to be there. What you can do is modify the template so that the username field is still there but hidden, and you only show the email field. Then when they submit the form you take the value from the email field and set the username to it.

You could add a workflow to the membership review list - it is just a SharePoint list. Alternatively you can look at the event receiver code for the membership review list in the FBA Pack. We run code when the status of an item changes, so you could potentially put your custom code in there as well.

Hi Chris,

I am using the below jquery code for copying the field element from email to username

$(document).ready(function () { $('CreateUserButton').click(function () { $('UserName').val($('Email').val()); }); }); but not able to copy the value once I click on create user button. can you please tell if I need amend the create user button code under membershiprequestwebpart.cs aswell? as I am just performing the copy on UI apart from createusersteptemplate.aspx I don't think to amend any here else in the pack. Thanks

I’ve always just done it in the cs code, never used js.

1 Like

you mean updating on MembershipRequestWebpart.cs ??

would it be possible to share the cs code please?

I think it was in MembershipRequestWebpart.cs that I made the change. Sorry I’d have to really dig for it - I can’t remember which project I did it in. If you google asp.net membership controls - the fba pack is just a wrapper for it. I’m sure you can find sample code for working with it there.

Also, I think you may need a greater level of help than these free support forums are meant for. You might want to look at our support plan:
https://www.visigo.com/products/sharepoint-fba-pack/support-plan/

It includes up to 4 hours of one-on-one consultation and can be used for custom development as well (we can make the changes for you).

1 Like

Hi Chris,
Thanks for reply.
I am trying to add the js script createuser.aspx which is just to get the email text filed when the email field is getting typed and I rendered the code in membershipwebpart.cs.

 function change(){
        var Email= document.getElementById('#ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');
        var UserName= document.getElementById('#ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');
        UserName.value=Email.value;
         } under membershiprequestwebpart.cs             sb2.AppendLine(@"<script language='javascript'>");
        sb2.AppendLine(@"function change(){");
        sb2.AppendLine(@"var Email= document.getElementById('#ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_Email');");
        sb2.AppendLine(@"var UserName= document.getElementById('#ctl00_ctl40_g_e7fed4bf_b25a_4a8a_943d_e31932556a9e_FBACreateUserWizard_CreateUserStepContainer_UserName');");
        sb2.AppendLine(@"UserName.value=Email.value;");
        sb2.AppendLine(@" }");
        sb2.Append(@"</script>"); if (!Page.ClientScript.IsStartupScriptRegistered("JSScript"))
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "JSScript", sb2.ToString());

        }

I have added basic onchange to the email field <asp:TextBox ID="Email" runat="server" onkeyup="change();"></asp:TextBox> and on aspx page the basic java script and rendered that though c#

when deployed I can see the java script on the create user page but not performing any action when typing the email field.
the tried the same script on code open and it working fine.

can I know why is membershiprequestwebpart.cs not accepting any javascript ,I am not rendering any thing on create user button it is just copying the email field into username when user typing this function will perform before click the create user button…

I am rendering under membershiprequestwebpart.cs
protected override void RenderContents(HtmlTextWriter writer)
{
}

Do I just need to add the code into c# without adding any code into aspx page?
your help would be much appreciated.

Thanks

Hi Chris,

I managed to sort the username field issue,

added the javascript on the aspx and rendered that code in c# using string builder and added hidden to the username field on server side script.

Thanks.