Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Pre populate alternative form field View modes: 
User avatar
Member
Member
eagleag - 5/12/2011 6:52:16 AM
   
Pre populate alternative form field
Hi,
I have an alternative form (site signup).
When webpart loads I would like to pre-populate some of the fields(textboxes).
example:
if I gathered persons FirstName that field should already show his FirstName.


How can I do this?
couldn't find any ".Set" function for doing this.

this is the setup code:
any examples on how to do this?


protected void SetupControl()
{
if (this.StopProcessing)
{
// Do nothing
}
else
{
// WAI validation
lblCaptcha.AssociatedControlClientID = captchaElem.InputClientID;

// Get alternative form info
AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeForm);
if (afi != null)
{
formUser.AlternativeFormFullName = this.AlternativeForm;
formUser.Info = new UserInfo();
formUser.ClearAfterSave = false;
formUser.Visible = true;
formUser.ValidationErrorMessage = this.RegistrationErrorMessage;
formUser.IsLiveSite = true;
// Reload form if not in PortalEngine environment and if post back
if ((this.StandAlone) && (RequestHelper.IsPostBack()))
{
formUser.ReloadData();
}



captchaElem.Visible = this.DisplayCaptcha;
lblCaptcha.Visible = this.DisplayCaptcha;
plcCaptcha.Visible = this.DisplayCaptcha;

btnRegister.Text = this.ButtonText;
btnRegister.Click += new EventHandler(btnRegister_Click);

formUser.OnBeforeSave += new DataForm.OnBeforeSaveEventHandler(formUser_OnBeforeSave);

lblInfo.CssClass = "EditingFormInfoLabel";
lblError.CssClass = "EditingFormErrorLabel";
}
else
{
lblError.Text = String.Format(ResHelper.GetString("altform.formdoesntexists"), AlternativeForm);
lblError.Visible = true;
pnlRegForm.Visible = false;
}
}
}

User avatar
Kentico Support
Kentico Support
kentico_radekm - 5/24/2011 6:54:27 AM
   
RE:Pre populate alternative form field
Hello.

You need to modify \CMSWebParts\Membership\Registration\CustomRegistrationForm.ascx.cs file like this:

1. Register BasicForm_OnAfterDataLoad() method via

formUser.BasicForm.OnAfterDataLoad += new BasicForm.OnAfterDataLoadEventHandler(BasicForm_OnAfterDataLoad);


In following condition:

if (formUser.BasicForm != null)
{
//
}


2. Write body of that method and same any value in your Alternative form according to example below:

void BasicForm_OnAfterDataLoad()
{
System.Web.UI.WebControls.TextBox textbox = (System.Web.UI.WebControls.TextBox)formUser.BasicForm.FieldControls["FirstName"];
textbox.Text = "some text";
}


Best Regards,
Radek Macalik