Feature Toggling for .net
C# ASP Shell
Latest commit d0d0d10 Dec 20, 2011 Steve Moyer changed more Condition to Conditional


Feature Toggling for .net

for more information on the concept of feature toggle see http://martinfowler.com/bliki/FeatureToggle.html

**** nToggle no longer supports appSettings and is now configured by using it's own configSection
<?xml version="1.0"?>
      <add name="TestFeatureOn" value="True"/>
      <add name="TestFeatureOff" value="False"/>
      /*The following toggle will associate a custom IFeatureToggleRepository with the given toggle.  
	    Custom repositories can enable things like A/B testing*/
      <add name="DynamicFeature" repository="nToggleDynamicFeatureTest,nToggleDynamicFeatureTest.TestDynamicRepository" value="True"/>
        <modules runAllManagedModulesForAllRequests="true"/>
        <compilation debug="true"/>

Remove controls from a web page based on a feature toggle:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ToggledOff.aspx.cs" Inherits="nToggleWebTestApp.ToggledOff" %>

<%@ Register assembly="nToggle" namespace="nToggle" tagprefix="nToggle" %>
<nToggle:WebFeatureToggle ID="FeatureToggle1" EnabledBy="TestFeatureOff" runat="server" >
    <span id="enabledby"> Feature Turned Off</span>
<nToggle:WebFeatureToggle ID="FeatureToggle2" RemovedBy="TestFeatureOff"  runat="server" >
    <span id="removedby">Feature Turned Off But Toggle is remove by feature</span>
 ************ Warning: Asp.net does not populate the  controls collection with inline script tags so the following is NOT valid 
<nToggle:WebFeatureToggle ID="FeatureToggle1" EnabledBy="TestFeatureOff" runat="server" >
    <span id="enabledby"> <%= "Feature Turned Off" %></span>

Run code in a Code Behind based on a feature toggle:
protected void Page_Load(object sender, EventArgs e)
        protected void CodeToRunIfDisabled()
        //your code
        protected void CodeToRunIfEnabled()
        //your code