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

Working With Component Attributes

This example demonstrates how to dynamically set value of a component attribute, in this case disabling textbox when users view their profile.
Let's assume that we have a TextBox named user_login, located in Registration form. The event code disables the textbox if the URL contains mode=profile.

  1. While in the HTML mode use the context menu to insert {user_login:disabled} attribute into TextBox template. The HTML should  look as follows:
    <input name="{user_login_Name}" value="{user_login}" {user_login:disabled}>
  2. Add 'Custom Code' action to the Before Show event of the TextBox.
  3. Use the code shown below within the action body:


   If CCGetFromGet("mode", "") = "profile" Then  _
      Sender.Attributes("disabled") = "disabled"


  if (CCGetParam('mode', '') == 'profile') {
    $Component->Attributes->SetValue('disabled', 'disabled');


  if (CCGetFromGet('mode', '') eq 'profile') {
    $Component->{Attributes}->SetValue('disabled', 'disabled');


  <CFPARAM Name="URL.mode" Default="">
  <CFIF URL.mode EQ "profile">
    <CFSET StructInsert(attrUser_login, "disabled", "disabled", True)>


  If Request.QueryString("mode") = "profile" Then
    ControlAttributes.Add(usersuser_login, New CCSControlAttribute("disabled", FieldType._Text, "true"))
  End If


  if (Request.QueryString["mode"] == "profile") {
  	ControlAttributes.Add(usersuser_login, new CCSControlAttribute("disabled", FieldType.Text, "true"));


  if ("profile".equals(e.getPage().getHttpGetParams().getParameter("mode"))) {

See Also:

On-line, printable versions and updates