Provides core functionality for authoring and validating complex business rules in a web client such as web browser. Implemented as ASP.NET server control.
The following code sample demonstrates how to save rules as a database XML type or XML file and load those rules back on the page for editing. The code declares a page that contains two Web Rule controls (AspControl1 and AspControl2) and two buttons (Button1 and Button2)
-
ClientOnly Type: System.Boolean
Gets or sets the value indicating if Web Rule should instantiate itself as pure JavaScript object to be used in client-side web application. The default value is False.
-
IsEmpty Type: System.Boolean
Gets the value indicating if Web Rule control is empty (contains no rule elements).
-
IsValid Type: System.Boolean
Gets the value indicating if the submitted rule passed automatic rule validation. Web Rule performs automatic validation every time a rule is submitted. If validation failed, Web Rule highlights all invalid elements. Rule authors can hover their mice over each invalid element to see details of the problem. The default English help document contains those validation details. It can be replaced with your own version. See HelpXml and HelpXmlFile properties for details.
-
ShowLineDots Type: System.Boolean
Gets or sets the value indicating if Web Rule control should display a small dot preceding each new line in the rule. The default value is False. See also the description of the CssClassElementNewLine property.
-
ShowMenuOnRightArrowKey Type: System.Boolean
Gets or sets the value indicating if Web Rule control should show context menu with items related to the current element every time the rule author uses Right Arrow key. Setting this value to true eliminates the need to hit the Space Bar to bring up the menu every time the author needs to insert or replace a rule element. The default value is True.
-
CacheHelp Type: System.Boolean
Gets or sets the value indicating if current help document that contains Help String and rule validation messages should be cached for faster retrieval. The default value is False.
-
HelpPosition Type: CodeEffects.Rule.Common.HelpPosition
Gets or sets the position of Help String related to the main control area. The value of HelpPosition.Off removes Help String from screen. If all Web Rule controls on the page have this value set to Off then Web Rule doesn't include help messages to page's source. This makes the size of the page smaller. The default value is HelpPosition.OnTop.
-
HelpXml Type: System.Xml.XmlDocument
Gets or sets XmlDocument object that contains default English help and validation messages shown in Help String. Plays the same role as HelpXmlFile (see its description below for details).
XmlDocument help = new XmlDocument();
help.LoadFile("C:\Help\Custom.config");
help.Load(customHelpXml);
AspControl1.HelpXml = help;
-
HelpXmlFile Type: System.String
Gets or sets virtual path to the XML file that contains default English help and validation messages shown in Help String. You use your own custom help by replacing the built-in document in case you'd like to change the default English messages or Web Rule is used in a multilingual project. To do that, first obtain the default XML document as string by calling AspControl.GetHelpXml(). Open the resulting string in any XML editor, edit messages (but not node names or document structure), save the file and load it with Web Rule:
AspControl1.HemlXmlFile = "/Help/Custom.config";
-
CacheSource Type: System.Boolean
Gets or sets the value indicating if source should be cached for faster retrieval or not. The default value is False.
-
SourceAssembly Type: System.String
Gets or sets the full name of referenced assembly that contains declaration of source object. This property is required if property SourceXml or SourceXmlFile is not set. This property is not required if the ClientOnly is set to True. You can obtain full name of source object's assembly by running Assembly.GetAssembly( SourceObjectType ).FullName. Source object topic discusses the use of this property in details.
-
SourceXml Type: System.Xml.XmlDocument
Gets or sets XmlDocument that defines structure of the source object. This structure is used by Web Rule to render its UI in the browser. The source object topic contains code samples on how to manipulate with the source.
-
SourceXmlFile Type: System.String
Gets or sets virtual path to the custom XML file that defines structure of the source object. This structure is used by Web Rule to render its UI in the browser. The source object topic contains code samples on how to manipulate with the source.
-
SourceType Type: System.String
Gets or sets the full name of source object type. This property is required if property SourceXml or SourceXmlFile is not set. This property is not required if the ClientOnly is set to True. You can obtain the source object's full name by running sourceObject.GetType().FullName. Source object topic discusses the use of this property in details.
-
ColorCurrentElementHighlight Type: System.String
Gets or sets background color of the currently selected rule elements. Accepts hexadecimal color codes such as "#FFFFFF" or standard web color names such as "Black".
-
ColorCursor Type: System.String
Gets or sets color of custom cursor used in Web Rule to aid navigation through the rule elements. Accepts hexadecimal color codes such as "#FFFFFF" or standard web color names such as "Black".
-
ColorHighlight Type: System.String
Gets or sets background color of invalid rule elements. The value of this property is also used to highlight sibling parentheses when pointer hovers over them. Accepts hexadecimal color codes such as "#FFFFFF" or standard web color names such as "Black".
-
CssClassDatePickerContainer Type: System.String
Gets or sets CSS class of the date picker container. Date picker allows rule authors to manually enter values of "date" fields. Date picker container is a TABLE tag.
-
CssClassDatePickerDay Type: System.String
Gets or sets CSS class of a cell that displays a single day in date picker. Date picker day is a TD tag.
-
CssClassDatePickerDayRollover Type: System.String
Gets or sets CSS hover class of a cell that displays a single day in date picker. Date picker day is a TD tag.
-
CssClassDatePickerHeader Type: System.String
Gets or sets CSS class of the header of date picker. Header displays currently selected year and month and contains buttons to select next or previous month and year. Date picker header is a TABLE tag.
-
CssClassDatePickerSelectedDay Type: System.String
Gets or sets CSS class of a cell that displays a selected day in date picker. Date picker day is a TD tag.
-
CssClassDatePickerToday Type: System.String
Gets or sets CSS class of a cell that has a value of today's date in date picker. Date picker day is a TD tag.
-
CssClassDatePickerWeekDay Type: System.String
Gets or sets CSS class of each cell that displays week days below the header of date picker. Date picker week day is a TD tag.
-
CssClassElementAction Type: System.String
Gets or sets CSS class of action element. Rule action elements are SPAN tags.
-
CssClassElementCalculation Type: System.String
Gets or sets CSS class of each element that are part of rule calculation. Rule calculation elements are SPAN tags.
-
CssClassElementClause Type: System.String
Gets or sets CSS class of clause element. Rule clause elements are SPAN tags.
-
CssClassElementField Type: System.String
Gets or sets CSS class of field element. Rule field elements are SPAN tags.
-
CssClassElementFlow Type: System.String
Gets or sets CSS class of flow element. Rule flow elements are SPAN tags.
-
CssClassElementNewLine Type: System.String
Gets or sets CSS class of new line element. New line elements are SPAN tags with non-breakable white space. These elements display the dots if the ShowLineDots property is set to True.
-
CssClassElementOperator Type: System.String
Gets or sets CSS class of operator element. Rule operator elements are SPAN tags.
-
CssClassElementParameter Type: System.String
Gets or sets CSS class of function or action parameter element. Parameter elements are SPAN tags.
-
CssClassElementParenthesis Type: System.String
Gets or sets CSS class of left or right parenthesis element. Rule parenthesis elements are SPAN tags.
-
CssClassElementTab Type: System.String
Gets or sets CSS class of tab element. Tab elements are SPAN tags.
-
CssClassElementValue Type: System.String
Gets or sets CSS class of value element. Value elements are SPAN tags.
-
CssClassHelpContainer Type: System.String
Gets or sets CSS class of Help String container. This container is a DIV tag.
-
CssClassMenuContainer Type: System.String
Gets or sets CSS class of Web Rule custom context menu container. This container is a DIV tag.
-
CssClassRuleContainer Type: System.String
Gets or sets CSS class of main Web Rule container. This container is a DIV tag.
-
CssClassTimePickerContainer Type: System.String
Gets or sets CSS class of the time picker container. Time picker allows rule authors to manually enter values of "time" fields. Time picker container is a TABLE tag.
-
Clear()
Returns: System.Void
Parameters: None
Removes all rule elements from control's UI.
-
ClearCache()
Returns: System.Void
Parameters: None
Removes all source and help entries written by the instance of Web Rule (but not other instances that might also be declared on the page) from server's cache. See HelpXml, HelpXmlFile, SourceXml and SourceXmlFile properties for details on source and help caching.
-
GetClientInvalidData()
Returns:
System.String
Parameters: None
Returns JSON string representing the array of rule elements that failed rule validation. This method is used in conjunction with the ClientOnly property when Web Rule is implemented as JavaScript object in client-side web application. Download the demo project to see the client-side implementation of Web Rule control.
-
GetClientRuleData()
Returns:
System.String
Parameters:
None
Returns JSON string representing elements of the rule. This method is used in conjunction with ClientOnly property when Web Rule is implemented as JavaScript object in client-side web application. Download the demo project to see the client-side implementation of Web Rule control.
-
GetClientSettings() Returns: System.String
Parameters: None
Returns string representation of the WebRule initialization on the page. This method is used in conjunction with ClientOnly property when Web Rule is implemented as JavaScript object in client-side web application. Download the demo project to see the client-side implementation of Web Rule control.
-
GetHelpXml() Returns: System.String
Parameters: None
Returns XML string of help document that contains default English messages used in Help String and rule validation. Use this method if you'd like to obtain and edit help document used by your copy of Web Rule. You might want to do this if you'd like to use your own Help String or validation messages or Web Rule control is used in multilingual project. See HelpXml and HelpXmlFile properties for details on how to load modified help documents. A copy of help document used in version 0.9.0.2 can be found here.
-
GetSourceXml() Returns: System.String
Parameters: None
Returns XML string of the source object used internally by Web Rule to render its UI. Use this XML if you'd like to speed up the rendering process on each request without caching the source. This speed increase typically is not significant. This method might be also used to manually edit the source document and load it into the Web Rule. The source object topic contains code samples on how to manipulate with the source.
-
GetRuleXml() Returns: System.String
Parameters: None
Returns string that contains XML document of the rule currently shown in Web Rule control. Check IsValid property to verify that the current rule is valid before calling this method. Otherwise, the InvalidRuleException will be thrown. Use the returned string to store the rule in a database as XML type or in a file system as XML file. This is the string that you pass to Evaluator.Execute or Evaluator.Evaluate to execute or evaluate your rule (depending on the rule type). You also use this string to load the rule into Web Rule's control for editing. Samples of code-behind classes on the demo page and the Implementation Example topic contain examples of usage of this method. Also, there is a code sample at the top of this topic that demonstrates a typical usage of this method as well.
-
LoadClientData(System.String) Returns: System.Void
Parameters:
- ruleClientData, System.String - JSON string that contains the current rule. It can be obtained by calling the client function $ce(webRuleClientId).extract(), where webRuleClientId is the DOM Id of Web Rule control.
Loads the rule into the instance of Web Rule for further processing on the server. This method is used by the server-side code to deserialize the client data into the rule source when Web Rule is implemented as JavaScript object in a client-side web application. Download the demo project to see the client-side implementation of Web Rule control.
-
LoadRuleFile(System.String) Returns: System.Void
Parameters:
- ruleXmlFileFullPath, System.String - Full path to the file that contains XML rule document. See GetRuleXml() method for details on obtaining rule XML document.
Loads the XML file that contains the rule document into the instance of Web Rule control. After successful load, the rule can be viewed and modified. There is a code sample at the top of this topic that demonstrates a typical usage of this method.
-
LoadRuleXml(System.String) Returns: System.Void
Parameters:
- ruleXml, System.String - XML document of a rule. See GetRuleXml() method for details on obtaining rule XML document.
Loads the XML string that contains the rule document into the instance of Web Rule control. After successful load, the rule can be viewed and modified. There is a code sample at the top of this topic that demonstrates a typical usage of this method.