protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CountryListBox.DataSource = Countries; CountryListBox.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { /////////////////////// Register a javascript function to check if page is in Ajax postback //////////////////// var script = String.Format("var isAjaxPostback = {0};", ScriptManager.GetCurrent(Page).IsInAsyncPostBack.ToString().ToLower()); ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "isAjaxPostback", script, true); if (!IsPostBack) { // Assign values of Personal Information section from user session data txtFirstName.Text = (string)Session[AppData.FIRSTNAME]; txtLastName.Text = (string)Session[AppData.LASTNAME]; lblCountry.Text = "Country: <strong>" + (string)Session[AppData.COUNTRY] + "</strong>"; CountryListBox.DataSource = Countries; CountryListBox.DataBind(); } }
/// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> protected override void OnLoad(EventArgs e) { base.OnLoad(e); cboCountry.SelectedIndexChanged += OnCountryIndexChanged; chkCell.CheckedChanged += OnCellCheckChanged; chkCity.CheckedChanged += OnCityCheckChanged; chkCountry.CheckedChanged += OnCountryCheckChanged; chkFax.CheckedChanged += OnFaxCheckChanged; chkPostal.CheckedChanged += OnPostalCheckChanged; chkRegion.CheckedChanged += OnRegionCheckChanged; chkStreet.CheckedChanged += OnStreetCheckChanged; chkTelephone.CheckedChanged += OnTelephoneCheckChanged; try { valStreet.ErrorMessage = Localization.GetString("StreetRequired", Localization.GetResourceFile(this, MyFileName)); valCity.ErrorMessage = Localization.GetString("CityRequired", Localization.GetResourceFile(this, MyFileName)); valCountry.ErrorMessage = Localization.GetString("CountryRequired", Localization.GetResourceFile(this, MyFileName)); valPostal.ErrorMessage = Localization.GetString("PostalRequired", Localization.GetResourceFile(this, MyFileName)); valTelephone.ErrorMessage = Localization.GetString("TelephoneRequired", Localization.GetResourceFile(this, MyFileName)); valCell.ErrorMessage = Localization.GetString("CellRequired", Localization.GetResourceFile(this, MyFileName)); valFax.ErrorMessage = Localization.GetString("FaxRequired", Localization.GetResourceFile(this, MyFileName)); if (!Page.IsPostBack) { txtStreet.TabIndex = Convert.ToInt16(StartTabIndex); txtUnit.TabIndex = Convert.ToInt16(StartTabIndex + 1); txtCity.TabIndex = Convert.ToInt16(StartTabIndex + 2); cboCountry.TabIndex = Convert.ToInt16(StartTabIndex + 3); cboRegion.TabIndex = Convert.ToInt16(StartTabIndex + 4); txtRegion.TabIndex = Convert.ToInt16(StartTabIndex + 5); txtPostal.TabIndex = Convert.ToInt16(StartTabIndex + 6); txtTelephone.TabIndex = Convert.ToInt16(StartTabIndex + 7); txtCell.TabIndex = Convert.ToInt16(StartTabIndex + 8); txtFax.TabIndex = Convert.ToInt16(StartTabIndex + 9); //<tam:note modified to test Lists //Dim objRegionalController As New RegionalController //cboCountry.DataSource = objRegionalController.GetCountries //<this test using method 2: get empty collection then get each entry list on demand & store into cache var ctlEntry = new ListController(); var entryCollection = ctlEntry.GetListEntryInfoItems("Country"); cboCountry.DataSource = entryCollection; cboCountry.DataBind(); cboCountry.Items.Insert(0, new ListItem("<" + Localization.GetString("Not_Specified", Localization.SharedResourceFile) + ">", "")); switch (_countryData.ToLower()) { case "text": if (String.IsNullOrEmpty(_country)) { cboCountry.SelectedIndex = 0; } else { if (cboCountry.Items.FindByText(_country) != null) { cboCountry.ClearSelection(); cboCountry.Items.FindByText(_country).Selected = true; } } break; case "value": if (cboCountry.Items.FindByValue(_country) != null) { cboCountry.ClearSelection(); cboCountry.Items.FindByValue(_country).Selected = true; } break; } Localize(); if (cboRegion.Visible) { switch (_regionData.ToLower()) { case "text": if (String.IsNullOrEmpty(_region)) { cboRegion.SelectedIndex = 0; } else { if (cboRegion.Items.FindByText(_region) != null) { cboRegion.Items.FindByText(_region).Selected = true; } } break; case "value": if (cboRegion.Items.FindByValue(_region) != null) { cboRegion.Items.FindByValue(_region).Selected = true; } break; } } else { txtRegion.Text = _region; } txtStreet.Text = _street; txtUnit.Text = _unit; txtCity.Text = _city; txtPostal.Text = _postal; txtTelephone.Text = _telephone; txtCell.Text = _cell; txtFax.Text = _fax; divStreet.Visible = _showStreet; divUnit.Visible = _showUnit; divCity.Visible = _showCity; divCountry.Visible = _showCountry; divRegion.Visible = _showRegion; divPostal.Visible = _showPostal; divTelephone.Visible = _showTelephone; divCell.Visible = _showCell; divFax.Visible = _showFax; if (TabPermissionController.CanAdminPage()) { chkStreet.Visible = true; chkCity.Visible = true; chkCountry.Visible = true; chkRegion.Visible = true; chkPostal.Visible = true; chkTelephone.Visible = true; chkCell.Visible = true; chkFax.Visible = true; } ViewState["ModuleId"] = Convert.ToString(_moduleId); ViewState["LabelColumnWidth"] = _labelColumnWidth; ViewState["ControlColumnWidth"] = _controlColumnWidth; ShowRequiredFields(); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <Summary>Page_Load runs when the control is loaded</Summary> protected void Page_Load(object sender, EventArgs e) { try { valStreet.ErrorMessage = Localization.GetString("StreetRequired", Localization.GetResourceFile(this, MyFileName)); valCity.ErrorMessage = Localization.GetString("CityRequired", Localization.GetResourceFile(this, MyFileName)); valCountry.ErrorMessage = Localization.GetString("CountryRequired", Localization.GetResourceFile(this, MyFileName)); valPostal.ErrorMessage = Localization.GetString("PostalRequired", Localization.GetResourceFile(this, MyFileName)); valTelephone.ErrorMessage = Localization.GetString("TelephoneRequired", Localization.GetResourceFile(this, MyFileName)); valCell.ErrorMessage = Localization.GetString("CellRequired", Localization.GetResourceFile(this, MyFileName)); valFax.ErrorMessage = Localization.GetString("FaxRequired", Localization.GetResourceFile(this, MyFileName)); if (!Page.IsPostBack) { if (!String.IsNullOrEmpty(_LabelColumnWidth)) { //lblCountry.Width = System.Web.UI.WebControls.Unit.Parse(_LabelColumnWidth) //lblRegion.Width = System.Web.UI.WebControls.Unit.Parse(_LabelColumnWidth) //lblCity.Width = System.Web.UI.WebControls.Unit.Parse(_LabelColumnWidth) //lblStreet.Width = System.Web.UI.WebControls.Unit.Parse(_LabelColumnWidth) //lblUnit.Width = System.Web.UI.WebControls.Unit.Parse(_LabelColumnWidth) //lblPostal.Width = System.Web.UI.WebControls.Unit.Parse(_LabelColumnWidth) //lblTelephone.Width = System.Web.UI.WebControls.Unit.Parse(_LabelColumnWidth) //lblCell.Width = System.Web.UI.WebControls.Unit.Parse(_LabelColumnWidth) //lblFax.Width = System.Web.UI.WebControls.Unit.Parse(_LabelColumnWidth) } if (!String.IsNullOrEmpty(_ControlColumnWidth)) { cboCountry.Width = System.Web.UI.WebControls.Unit.Parse(_ControlColumnWidth); cboRegion.Width = System.Web.UI.WebControls.Unit.Parse(_ControlColumnWidth); txtRegion.Width = System.Web.UI.WebControls.Unit.Parse(_ControlColumnWidth); txtCity.Width = System.Web.UI.WebControls.Unit.Parse(_ControlColumnWidth); txtStreet.Width = System.Web.UI.WebControls.Unit.Parse(_ControlColumnWidth); txtUnit.Width = System.Web.UI.WebControls.Unit.Parse(_ControlColumnWidth); txtPostal.Width = System.Web.UI.WebControls.Unit.Parse(_ControlColumnWidth); txtTelephone.Width = System.Web.UI.WebControls.Unit.Parse(_ControlColumnWidth); txtCell.Width = System.Web.UI.WebControls.Unit.Parse(_ControlColumnWidth); txtFax.Width = System.Web.UI.WebControls.Unit.Parse(_ControlColumnWidth); } txtStreet.TabIndex = Convert.ToInt16(_StartTabIndex); txtUnit.TabIndex = Convert.ToInt16(_StartTabIndex + 1); txtCity.TabIndex = Convert.ToInt16(_StartTabIndex + 2); cboCountry.TabIndex = Convert.ToInt16(_StartTabIndex + 3); cboRegion.TabIndex = Convert.ToInt16(_StartTabIndex + 4); txtRegion.TabIndex = Convert.ToInt16(_StartTabIndex + 5); txtPostal.TabIndex = Convert.ToInt16(_StartTabIndex + 6); txtTelephone.TabIndex = Convert.ToInt16(_StartTabIndex + 7); txtCell.TabIndex = Convert.ToInt16(_StartTabIndex + 8); txtFax.TabIndex = Convert.ToInt16(_StartTabIndex + 9); // <tam:note modified to test Lists //Dim objRegionalController As New RegionalController //cboCountry.DataSource = objRegionalController.GetCountries // <this test using method 2: get empty collection then get each entry list on demand & store into cache ListController ctlEntry = new ListController(); ListEntryInfoCollection entryCollection = ctlEntry.GetListEntryInfoCollection("Country"); cboCountry.DataSource = entryCollection; cboCountry.DataBind(); cboCountry.Items.Insert(0, new ListItem("<" + Localization.GetString("Not_Specified", Localization.SharedResourceFile) + ">", "")); switch (_CountryData.ToLower()) { case "text": if (_Country == "") { cboCountry.SelectedIndex = 0; } else { if (cboCountry.Items.FindByText(_Country) != null) { cboCountry.ClearSelection(); cboCountry.Items.FindByText(_Country).Selected = true; } } break; case "value": if (cboCountry.Items.FindByValue(_Country) != null) { cboCountry.ClearSelection(); cboCountry.Items.FindByValue(_Country).Selected = true; } break; } Localize(); if (cboRegion.Visible) { switch (_RegionData.ToLower()) { case "text": if (_Region == "") { cboRegion.SelectedIndex = 0; } else { if (cboRegion.Items.FindByText(_Region) != null) { cboRegion.Items.FindByText(_Region).Selected = true; } } break; case "value": if (cboRegion.Items.FindByValue(_Region) != null) { cboRegion.Items.FindByValue(_Region).Selected = true; } break; } } else { txtRegion.Text = _Region; } txtStreet.Text = _Street; txtUnit.Text = _Unit; txtCity.Text = _City; txtPostal.Text = _Postal; txtTelephone.Text = _Telephone; txtCell.Text = _Cell; txtFax.Text = _Fax; rowStreet.Visible = _ShowStreet; rowUnit.Visible = _ShowUnit; rowCity.Visible = _ShowCity; rowCountry.Visible = _ShowCountry; rowRegion.Visible = _ShowRegion; rowPostal.Visible = _ShowPostal; rowTelephone.Visible = _ShowTelephone; rowCell.Visible = _ShowCell; rowFax.Visible = _ShowFax; if (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName)) { chkStreet.Visible = true; chkCity.Visible = true; chkCountry.Visible = true; chkRegion.Visible = true; chkPostal.Visible = true; chkTelephone.Visible = true; chkCell.Visible = true; chkFax.Visible = true; } ViewState["ModuleId"] = Convert.ToString(_ModuleId); ViewState["LabelColumnWidth"] = _LabelColumnWidth; ViewState["ControlColumnWidth"] = _ControlColumnWidth; ShowRequiredFields(); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }