CodeCharge Studio | All ASP PHP Perl ColdFusion Java C#.NET VB.NET |
This example shows how to change the value of a Label control before it is shown. In particular, we have a Grid called Tasks which has a Label field called Priority. We shall add event code so that the color of the Label text changes depending on the field value (red for high, black for normal, and green for low priority).
Function Tasks_Priority_BeforeShow(Sender) If Tasks.Priority.Value = "High" Then Tasks.Priority.Value = "<font color=RED>"&Tasks.Priority.Value&"</font>" Elseif Tasks.Priority.Value = "Low" Then Tasks.Priority.Value = "<font color=GREEN>"&Tasks.Priority.Value&"</font>" End if End Function
function Tasks_Priority_BeforeShow(& $sender) { global $Tasks; if ($Tasks->Priority->GetValue() == "High") { $Tasks->Priority->SetValue("<font color=RED>".$Tasks->Priority->GetValue()."</font>"); } else if ($Tasks->Priority->GetValue() == "Lowest") { $Tasks->Priority->SetValue("<font color=GREEN>".$Tasks->Priority->GetValue()."</font>"); } }
sub Tasks_Priority_BeforeShow() { if ($Tasks->{Priority}->GetValue() eq "High") { $Tasks->{Priority}->SetValue("<font color=RED>".$Tasks->{Priority}->GetValue()."</font>"); } elsif ($Tasks->{Priority}->GetValue() eq "Lowest") { $Tasks->{Priority}->SetValue("<font color=GREEN>".$Tasks->{Priority}->GetValue()."</font>"); } }
<!---Tasks_Priority_BeforeShow ---> <CFIF fldPriority EQ "High"> <CFSET fldPriority="<font color=RED>#fldPriority#</font>"> <CFELSEIF fldPriority EQ "Lowest"> <CFSET fldPriority="<font color=GREENRED>#fldPriority#</font>"> </CFIF>
'Tasks_Priority_BeforeShow If TasksPriority.Text = "High" Then TasksPriority.Text = ("<font color=RED>"&(TasksPriority.Text).ToString()&"</font>").ToString() ElseIf TasksPriority.Text = "Lowest" Then TasksPriority.Text = ("<font color=GREEN>"&(TasksPriority.Text).ToString()&"</font>").ToString() End if
//Tasks_Priority_BeforeShow if (TasksPriority.Text == "High") { TasksPriority.Text = "<font color=RED>"+TasksPriority.Text+"</font>"; } else if (TasksPriority.Text == "Lowest") { TasksPriority.Text = "<font color=GREEN>"+TasksPriority.Text+"</font>"; }
//Tasks_Priority_BeforeShow if ("High".equals(e.getControl().getValue())) { e.getControl().setValue("<font color=RED>"+e.getControl().getValue()+"</font>"); } else if ("Low".equals(e.getControl().getValue())) { e.getControl().setValue("<font color=GREEN>"+e.getControl().getValue()+"</font>"); }
<!-- BEGIN Row --> <tr> <td class="ClearDataTD">{task_name} </td> <td class="ClearDataTD">{project_name} </td> <td class="ClearDataTD">{status_name} </td> <td class="ClearDataTD"><font color="{Priority_Color}">{Priority}</font> </td> <td class="ClearDataTD">{date_resolve} </td> </tr> <!-- END Row -->
Function Tasks_BeforeShowRow() If Tasks.Priority.Value = "High" Then Tasks.Priority_Color.Value = "RED" ElseIf Tasks.Priority.Value = "Lowest" Then Tasks.Priority_Color.Value = "GREEN" Else Tasks.Priority_Color.Value = "BLACK" End if End Function
function Tasks_BeforeShowRow() { global $Tasks; if ($Tasks->Priority->GetValue() == "High") { $Tasks->Priority_Color->SetValue("RED"); } else if ($Tasks->Priority->GetValue() == "Lowest") { $Tasks->Priority_Color->SetValue("GREEN"); } else { $Tasks->Priority_Color->SetValue("BLACK"); } }
sub Tasks_BeforeShowRow() { if ($Tasks1->{Priority}->GetValue() eq "High") { $Tasks1->{Priority_Color}->SetValue("RED"); } elsif ($Tasks1->{Priority}->GetValue() eq "Lowest") { $Tasks1->{Priority_Color}->SetValue("GREEN"); } else { $Tasks1->{Priority_Color}->SetValue("BLACK"); } }
//Tasks BeforeShowRow if ("High".equals(e.getGrid().getControl("Priority").getValue())) { e.getGrid().getControl("Priority_Color").setValue("RED"); } else if ("Lowest".equals(e.getGrid().getControl("Priority").getValue())) { e.getGrid().getControl("Priority_Color").setValue("GREEN"); } else { e.getGrid().getControl("Priority_Color").setValue("BLACK"); }