// ddlCountries_SelectedIndexChanged routine resets the list of states or changes the state input control to a text box
// The only way this code triggers the change right away (in a drop down list) is if AutoPostBack is *true (in the list
// of properties for the drop down list box)
// Ajax update panel allows refresh of just a portion of the browser window/display
BegSr ddlCountries_SelectedIndexChanged Access(*Private) Event(*This.ddlCountries.SelectedIndexChanged)
DclSrParm sender Type(*Object)
DclSrParm e Type(System.EventArgs)
clsFdnWebCS.stcAddToSsttEvnLog2( strThisPageURL, clsFdnWebCS.stcstrfctGetCtrlID(sender *as Control) + "_Click", *ByRef *base.strbldrEvtLogBase )
if (ddlCountries.SelectedValue() *eq "CA")
ddlStates.DataSource = Application["asv_lstitmcolCAProvinces"] *as ListItemCollection
ddlStates.DataTextField = "text"
ddlStates.DataValueField = "value"
ddlStates.DataBind()
ddlStates.Visible = *true
tbState.Visible = *false
else
if (ddlCountries.SelectedValue() *eq "US")
ddlStates.DataSource = Application["asv_lstitmcolUSStates"] *as ListItemCollection
ddlStates.DataTextField = "text"
ddlStates.DataValueField = "value"
ddlStates.DataBind()
ddlStates.Visible = *true
tbState.Visible = *false
else
ddlStates.Visible = *false
tbState.Visible = *true
endif
endif
// country was changed, so if states is visible it still needs to be selected
if (ddlStates.Visible)
ddlStates.Focus()
else
tbState.text = *blank
tbZip.Text = *blank
tbState.Focus()
endif
EndSr
//**************************************************************************************************
// Populate RegisterTCAdvAppState Page from existing data or initialize for initial data creation
//**************************************************************************************************
BegSr srPopulateOrInzPageUI
// populate application state data coming from database if not already done
if (Application["AppStateReady"] *as *boolean <> *true)
// event log tracking contained within class
enterlock (nsFdnAnyCtxCS10.clsFdnAnyCtxCS10.objSingleThreadEnforcer)
DclFld clsAppViewStateFromDB type(clsAppViewState)
clsAppViewStateFromDB = *new clsAppViewState("RegisterTCAdvAppState.aspx", *base.strbldrEvtLogBase)
clsAppViewStateFromDB.Populate(strThisPageURL)
// this one automatically closes at the end of the populate routine
exitlock
endif
//****************************************************************************
// populate country (ddlCoutries) and state (ddlStates) drop down list boxes
//****************************************************************************
// population of ddlStates shows the most efficient way of using a static list that is based on information
// in a database (in a web app). Initial creation of the static list is done once for all users in
// Application_Start in global.asax
// For the drop down list of countries, we need to take advantage of method .FindByValue, thus we need to add one
// line of code that translates the application state variable into a ListItemCollection object (in this class)
// (apvlstitmcolCountries is a ListItemCollection that has been serialized (translated into a byte stream)
// (she ain't alive :-) / can't run methods on it / list of properties that work is very limited))
// So we populate ddlCountries control with a/the ListItemCollection object, lstitmcolCountries, that is instanced
// please note that this example takes advantage of the fact that the drop down lists are kept around by use of
// the page level viewstate
// retrieve the list item collection application state variable as a list item collection object type
// this session variable is created during the application event Application_Start in global.asax
// if we did not need the .IndexOf method from the ListItemCollection then we could have bound the drop down
// list box directly to the application state data as a ListItemCollection as is done (below) for ddlStates
// We also/still could have eliminated declaration of the ListItemCollection by storing the index of the "US"
// in a 2nd application viewstate collection member
// retrieve the list item collection application state variable as a list item collection object type
// and point to it as the data source
// this session variable is created during the application event Application_Start in global.asax
DclFld lstitmcolCountries Type(System.Web.UI.WebControls.ListItemCollection)
lstitmcolCountries = Application["asv_lstitmcolCountries"] *as ListItemCollection
ddlCountries.DataSource = lstitmcolCountries
// we need some magic to get both the country code (2,A) and country name (30,A) to be usable as separate entities
// evidentally the default column? names for a list item collection are "text" and "value"?
ddlCountries.DataTextField = "text"
ddlCountries.DataValueField = "value"
// ok, this is required to finish the populating the data for the drop down list box
// and then pointing? to it
ddlCountries.DataBind()
// show UNITED STATES (as default selection)
ddlCountries.SelectedIndex = lstitmcolCountries.IndexOf(lstitmcolCountries.FindByValue("US"))
// populate the states drop down list in a similar manner knowing we defaulted the country selection to "US"
// we have 2 state list item collections, one for US and one for Canada, that's it so far
// the two lists have been hard-coded in terms of access and data binding but not in the database
// if we get more states lists, it will make sense to fill them in at run time
// if another state or territory is added to the "CA" or "US" lists, nothing else needs to be done
// (although the web application has to go down and come back up for it to show in the list)
ddlStates.DataSource = Application["asv_lstitmcolUSStates"] *as ListItemCollection
ddlStates.DataTextField = "text"
ddlStates.DataValueField = "value"
ddlStates.DataBind()
ddlStates.Visible = *true
tbState.Visible = *false
if (*base.clsCustCtcActs.boolpropSignInStatus *eq *false)
...
EndSr
//*********************************************
// change user interface based on data values
//*********************************************
BegSr SetUIProperties
if (ViewState["vsv_ProcessingMode"].ToString() = "Update")
*this.Page.Title = "Update My Web User Profile"
btnAccept.Text = "Update Record"
else
*this.Page.Title = "Create My Account Information"
btnAccept.Text = "Create Record"
endif
//**********************************************************************************************
// basically you can make a html table row invisible through the .visible property for the row
// the cells can still be set to visible as well as the imbedded .webcontrols (yea!)
//**********************************************************************************************
// if (cbContactMe.Checked = *true *or tbPhoneNumber.Text <> *blank)
// tr6.Visible = *true
// tr6.Cells[0].Visible = *true
// tr6.Cells[1].Visible = *true
// else
// tr6.Visible = *false
// tr6.Cells[0].Visible = *false
// tr6.Cells[1].Visible = *false
// endif
// let's softcode access of the row, and base the row object on what houses the text box we want to make invisible
// 1) create a row object instanced to *nothing
DclFld htmltblrowObject type(System.Web.UI.HtmlControls.HtmlTableRow) new()
DclFld boolWork type(*boolean)
// let's make the address invisible so it looks like it's easy and fast to sign up
if (cbSendPromoLit.Checked *eq *true *or +
ddlCountries.SelectedValue() *ne "US" *or +
ddlStates.SelectedValue() *ne "**" *or +
tbState.Text *ne *blank *or +
tbAddressLine1.Text *ne *blank *or +
tbAddressLine2.Text *ne *blank *or +
tbCity.Text *ne *blank *or +
tbZip.Text *ne *blank)
boolWork = *true
else
boolWork = *false
endif
*base.SetHtmlTableRowReference("ddlCountries", *ByRef htmltblrowObject)
htmltblrowObject.Visible = boolWork
*base.SetHtmlTableRowReference("tbAddressLine1", *ByRef htmltblrowObject)
htmltblrowObject.Visible = boolWork
*base.SetHtmlTableRowReference("tbAddressLine2", *ByRef htmltblrowObject)
htmltblrowObject.Visible = boolWork
*base.SetHtmlTableRowReference("tbCity", *ByRef htmltblrowObject)
htmltblrowObject.Visible = boolWork
Endsr
|