Using Properties with Chameleon Forms

Community Server Chameleon Forms are placed on an .ASPX page like any ASP.NET control, with each control within the form declared when its created.  Here’s an example.

<DBVT:LaborUpdateForm ID=”LaborUpdateForm1″ runat=”server”
    LaborPhaseDropDownListId=”PhaseDropDown”
    LaborShiftDropDownListId=”ShiftDropDown” HoursTextBoxId=”HoursTextBox”
    UpdateButtonId=”UpdateButton”>

It’s easy to think of a Chameleon form as strictly a collection of controls, but you can use properties to affect the form’s behavior as well.  Take the following example.

 

Circled in red are two properties we’ve added so that we can reuse the form in different scenarios.  They are handled in the form’s code-behind similar to controls.

public string TabPanel
{
    get { return ((string)ViewState[“TabPanel”]) ?? string.Empty; }
    set { ViewState[“TabPanel”] = value; }
}

…..

string _tabPanel = “-1”;
if (!string.IsNullOrEmpty(this.TabPanel))
{
    _tabPanel = this.TabPanel;
}

string _employeeID = JobEmployeeDropDownList.SelectedItem.Value;
string _querystring = “?employeeID=” + _employeeID + “&tabpanel=” + _tabPanel;

HttpContext.Current.Response.Redirect(
    JobUrls.Instance().LaborSummaryAllJobs((WeblogPost)post,
    post.Weblog, _querystring));

 

One unrelated but interesting Community Server nerd point specific to this example.  In the final code statement where we do a Response.Redirect() to a custom Url, notice that we don’t always have to embed values into the SiteUrls.config URL Format statement.  If, as in this case when we’re using a multi-purpose page, it’s quite efficient to simply append a querystring to an existing Community Server Url.

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.