protected void SubmitOpenRegistrationButton_Click(object sender, EventArgs args)
        {
            if (!Page.IsValid)
            {
                return;
            }

            var attributes = new Dictionary <string, string>
            {
                { "firstname", ContentUtility.HtmlEncode(FirstName.Text) },
                { "lastname", ContentUtility.HtmlEncode(LastName.Text) },
                { "emailaddress1", ContentUtility.HtmlEncode(Email.Text) },
            };

            var returnUrl = Request[ReturnUrlKey];

            if (!string.IsNullOrWhiteSpace(returnUrl))
            {
                attributes.Add(ReturnUrlKey, returnUrl);
            }

            var fam = new CrmFederationAuthenticationModule(Context);

            if (fam.CanReadSignInResponse(Request, true))
            {
                // this is already a sign-in post, authenticate the user

                fam.TryHandleSignInResponse(Context, attributes, RegistrationSettings);
            }
            else
            {
                // redirect to get the sign-in token

                fam.RedirectToSignIn(Context, attributes);
            }
        }