Guides (SDK /API)Technical ReferenceBBDNHow-to Documentation

You are here: Custom Parts Example: Pledge Form > Populate the Name Fields

Populate the Name Fields

Code sample project: Custom Pledge Form

  1. From Visual Studio, open the code-behind VB file for CustomPledgeFormDisplay.ascx (CustomPledgeFormDisplay.ascx.vb).

  2. Create a InitializeForm Sub for the custom pledge form.

  3. Call the InitializeForm Sub from the Page_Load Sub.

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            InitializeForm()
        End Sub
  4. In the InitializeForm sub, check to see whether the current user is anonymous.

    Use the CurrentUser property in the BBNCExtensions.API.Users namespace to get the current user. Users have the IsAnonymous property.

    Not API.Users.CurrentUser.IsAnonymous
  5. Create a conditional that uses the value of the check as a condition. If the user is not anonymous, assign FirstName for CurrentUser to the text of TextBoxFirst and LastName to TextBoxLast. Then disable each name field by setting the Enabled property for the field to False.

    If the user is anonymous, leave the fields alone.

        Private Sub InitializeForm()
            'If there is a login, get the first and last name for the logged in user.
            'Populate the First and Last fields on the form. Disable the First, Middle,
            'and Last fields. Otherwise, leave the fields enabled and writeable.
            If Not API.Users.CurrentUser.IsAnonymous Then
                TextBoxFirst.Text = API.Users.CurrentUser.FirstName
                TextBoxLast.Text = API.Users.CurrentUser.LastName
                TextBoxFirst.Enabled = False
                TextBoxMiddle.Enabled = False
                TextBoxLast.Enabled = False
            End If
        End Sub
  6. After you build the project and copy the files to your BBIS installation, the part should behave as follows:

    When accessed without logging in...

    While logged in, as Supervisor in this case...