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

Hiding a Record Form Control

This example shows how to hide a control on a Record form. In this case, a Record form called Responses has a Text box control called Author that should not be displayed.

  1. Switch to HTML mode and locate the code for the Author Textbox control. Just before the code for the Author Textbox control, add the code <!-- BEGIN TextBox Author --> then after the code for the Author Textbox control, add the code <!-- END TextBox Author -->:
      <tr> 
        <td>Author</td>
        <td>
        <!-- BEGIN TextBox Author -->
          <input name="Author" value="{Author}">
        <!-- END TextBox Author -->
        </td>
      </tr>
    Or you can also add the code at the beginning and at the end of the table row to hide the control together with its caption:
    <!-- BEGIN TextBox Author -->
    <tr> 
      <td>Author</td>   
      <td><input name="Author" value="{Author}"></td>
    </tr>
    <!-- END TextBox Author -->


Control Level

One way to hide a control is to place code in the Before Show event of the control itself. Another method is to add code in the Before Show event of the form in which the control is contained. We shall begin with the first method where the code is added to the Before Show event of the control itself.

  1. Add the Before Show event to the control.
  2. Within the event, add the code below:

ASP

Function Responses_Author_BeforeShow()

   Responses.Author.Visible = False  

End Function

PHP

function Responses_Author_BeforeShow() {
global $Responses;

   $Responses->Author->Visible = False;

}

Perl

sub Responses_Author_BeforeShow() {

   $Responses->{Author}->{Visible} = 0;

}

ColdFusion

<!---Responses_Author_BeforeShow --->

  <CFSET hideAuthor = True>

VB.Net

'Responses_Author_BeforeShow

  ResponsesAuthor.Visible = False

C#

//Responses_Author_BeforeShow

  ResponsesAuthor.Visible = false;

Java

//Responses_Author_BeforeShow

  e.getControl().setVisible(false);

Form Level

The second method of hiding controls is to place code in the Before Show event of the form in which the control is contained. Using this method, you can hide multiple controls within the form since they are all accessible at the form level. This is not the case when the code is added to the Before Show event of one of the controls.

  1. Add the Before Show event to the form.
  2. Within the event, add the code below:

ASP

Function Responses_BeforeShow()

   Responses.Author.Visible = False  
   Responses.AuthorEmail.Visible = False  

End Function

PHP

function Responses_BeforeShow() {
global $Responses;

   $Responses->Author->Visible = False;
   $Responses->AuthorEmail->Visible = False;

}

Perl

sub Responses_BeforeShow() {

   $Responses->{Author}->{Visible} = 0;
   $Responses->{AuthorEmail}->{Visible} = 0;  

}

ColdFusion

<!---Responses_BeforeShow --->

  <CFSET hideAuthor = True>

VB.Net

'Responses_BeforeShow

  ResponsesAuthor.Visible = False

C#

//Responses_BeforeShow

  ResponsesAuthor.Visible = false;

Java

//Responses_BeforeShow

  e.getRecord().getControl("Author").setVisible(false);

See Also:

Before Show event, How to create a dynamic Login Control


On-line, printable versions and updates