This topic is locked
[SOLVED]

 Conditional Formatting on List Page

5/2/2018 12:25:56 PM
ASPRunner.NET General questions
N
nfgcgrb author

Help please on two issues.
First issue:

On the view page, I used the code below, the field defined as ANS-ANSI Requirements works and returns text in Red, however the ANSI field does not.
Before Display

pageObject.setProxyValue("ANSI", values["ANSI"]);
JavaScript OnLoad event

var ctrlValueA = Runner.getControl(pageid, 'ANSI');

var ctrlFieldB = Runner.getControl(pageid, 'ANS_ANSI_Requirements');
if(proxy['ANSI']=="Y"){

ctrlFieldB.addStyle('color: red;');

ctrlFieldA.addStyle('color: red;');}
Second issue:
When I try the same code on the List page, it fails to build, the build seems to be related to the before display values.
The build error log contains:
\\ HR_Tools.csproj

Microsoft (R) Build Engine version 4.7.2053.0

[Microsoft .NET Framework, version 4.0.30319.42000]

Copyright (C) Microsoft Corporation. All rights reserved.
\\ HR_ToolsEventsCS.csproj

Microsoft (R) Build Engine version 4.7.2053.0

[Microsoft .NET Framework, version 4.0.30319.42000]

Copyright (C) Microsoft Corporation. All rights reserved.
include\dbo_Nuclear_Job_Descriptions_Active_TableEvents.cs(38,34): error CS0103: The name 'values' does not exist in the current context [Y:\inetpub\wwwroot\NSPRoot\HRTools\HR_ToolsEventsCS.csproj]

admin 5/2/2018

This code doesn't make much sense on the List page. On View page you only have one record and you can access field values via values array. On List page you can multiple records and BeforeDisplay event only called once per page. Also Javascript API won't work on List page because there are no controls there.
This article explains how to conditionally format data on List page:

https://xlinesoft.com/asprunnernet/docs/conditional_formatting.htm

N
nfgcgrb author 5/3/2018



This code doesn't make much sense on the List page. On View page you only have one record and you can access field values via values array. On List page you can multiple records and BeforeDisplay event only called once per page. Also Javascript API won't work on List page because there are no controls there.
This article explains how to conditionally format data on List page:

https://xlinesoft.com/asprunnernet/docs/conditional_formatting.htm


Thanks, on my first question, what am I doing wrong for only one of my values to appear in red. That helped some on my second issue, Thank you!
string color;
if (data["ANSI"] == "Y") {
color="RED";
}else {
color="BLACK";
}
value="<span style='color: " + color + "'>" + value.ToString() + "</span>";

admin 5/3/2018

I'm not seeing anything wrong with the code. Make sure that ANSI field in fact contains 'Y' values. It will not work if it contains 'y' or 'Y '.

N
nfgcgrb author 5/8/2018



I'm not seeing anything wrong with the code. Make sure that ANSI field in fact contains 'Y' values. It will not work if it contains 'y' or 'Y '.


Some of the data had trailing spaces, once I removed them, it worked. Thank you