CodeCharge Studio All ASP PHP Perl ColdFusion Java C#.NET VB.NET

Dynamic Login Field in a Registration Form

This example shows how to use a Login control on a registration form.

Assume that you have a Registration Record form with a Logi nText Box control where users can enter a Login name when creating a record

but existing users should not be able to change the Login name

  1. Create a registration form.
  2. Click on the Text Box icon in the Forms tab of the Toolbox to add the Login Text Box control. In the same tab click on the Label icon to add a Label control directly after the Login Textbox.
  3. Set the name of the Label control to Login_View.
  4. Add <!-- BEGIN TextBox Login --> at the beginning and <!-- END TextBox Login --> at the end of the Login Textbox.
  5. Add <!-- BEGIN Label Login_View --> at the beginning and <!-- END Label Login_View --> at the end of the Login Label.
  6. The illustration below shows how the Login will look:
  7. Add a Before Show event for the Record form.
  8. Within the event, add the code below:

PS: Don't forget to retrieve the login value in the edit mode

ASP

Function Registration_BeforeShow(Sender)

  If (Registration.EditMode) Then
      'Edit Mode
      Registration.Login.Visible=False
  Else
      'Add Mode
      Registration.Login_View.Visible=False
  End If

End Function

PHP

function Registration_BeforeShow(& $sender) {
global $Registration;

  if ($Registration->EditMode) {
      //Edit Mode
      $Registration->Login->Visible = False;
  } else {
      //Add Mode
      $Registration->Login_View->Visible = False;
  }

}

Perl

sub Registration_BeforeShow() {

  if ($Registration->{EditMode} == 1) {
    #Edit Mode
    $Registration->{Login}->{Visible} = 0;
  } else {
    #Add Mode
    $Registration->{Login_View}->{Visible} = 0;
  }
  
}

ColdFusion

<!--Registration_BeforeShow --->
  <CFIF blnEditModeRegistration>
    <CFSET hideLogin=True>
  <CFELSE>
    <CFSET hideLogin_View=True>
  </CFIF>
   

VB.Net

'Registration_BeforeShow

  If (IsInsertMode) Then
    RegistrationLogin_View.Visible = False
  Else 
    RegistrationLogin.Visible = False
  End if
  

C#

//Registration_BeforeShow

  if (IsInsertMode) {
    RegistrationLogin_View.Visible = false;
  } else {
    RegistrationLogin.Visible = false;
  }
  

Java

//Registration_BeforeShow

  if (e.getRecord().isEditMode()) {
    //Edit Mode
    e.getRecord().getControl("Login").setVisible(false);
  } else {
    //Add Mode
    e.getRecord().getControl("Login_View").setVisible(false);
  }
  

See also:

BeforeShow event, How to hide a record control


On-line, printable versions and updates