Thursday, May 26, 2011

A new way of Enable/Disable features

EnableFeature.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MyWebRepo
{
public partial class EnableFeature : System.Web.UI.Page
{
public bool feature_enable = false;

protected void Page_Load(object sender, EventArgs e)
{

}
}
}

EnableFeature.aspx

body
form

<%-- Traditional Logic : We, used to check the settings in CodeBehind file and then set btnAbc.Visible=false :(
Why do we take extra-burdon to load and hide it; What happen if we do not create the button at all. So we turns to "New Logic"
--%>
<%-- New Logic :Use if in the webpage to check if the feature enabled/disabled. We may read the settings from DB also --%>

<% if (feature_enable)
{ %>
Button ID="btnAbc" runat="server" Text="My Button"

<% } %>


/form
/body

No comments:

Post a Comment