private ShippingMethodAndRate GetSelectedShippingMethod() { ShippingMethodAndRate selectedShippingMethod = null; foreach (RepeaterItem shippingMethod in rptShippingMethods.Items) { GlobalRadioButton rdo = shippingMethod.FindControl("rdoChooseShipping") as GlobalRadioButton; if (rdo != null && rdo.Checked) { //this is the selected method. Get the related shipping method id and return HiddenField hiddenShippingMethodId = shippingMethod.FindControl("hiddenShippingMethodId") as HiddenField; HiddenField hiddenShippingMethodName = shippingMethod.FindControl("hiddenShippingMethodName") as HiddenField; HiddenField hiddenRate = shippingMethod.FindControl("hiddenRate") as HiddenField; if (hiddenShippingMethodId != null && hiddenShippingMethodName != null) { Guid methodId = new Guid(hiddenShippingMethodId.Value); string methodName = hiddenShippingMethodName.Value; decimal rate = 0m; if (decimal.TryParse(hiddenRate.Value, out rate)) { selectedShippingMethod = new ShippingMethodAndRate(methodName, string.Empty, rate, methodId); } break; } } } return(selectedShippingMethod); }
/// <summary> /// Handles the ItemDataBound event of the PaymentOptionList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.DataListItemEventArgs"/> instance containing the event data.</param> protected void PaymentOptionList_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { if (e.Item.DataItem == null) { return; } PaymentMethodDto.PaymentMethodRow listItem = ((PaymentMethodDto.PaymentMethodRow)((DataRowView)e.Item.DataItem).Row); // Check the item if it has been already selected if (ViewState["PaymentMethod"] != null) { Guid selectedPayment = new Guid(ViewState["PaymentMethod"].ToString()); if (listItem.PaymentMethodId == selectedPayment) { GlobalRadioButton radioButton = (GlobalRadioButton)e.Item.FindControl("PaymentOption"); radioButton.Checked = true; } } // Retrieve the Label control in the current DataListItem. PlaceHolder optionPane = (PlaceHolder)e.Item.FindControl("PaymentOptionHolder"); System.Web.UI.Control paymentCtrl = StoreHelper.LoadPaymentPlugin(this, listItem.SystemKeyword); paymentCtrl.ID = listItem.SystemKeyword; paymentCtrl.EnableViewState = true; optionPane.Controls.Add(paymentCtrl); //TestPaymentOptionHolder.Controls.Add(paymentCtrl); } }
public string BindPaymentControls(PaymentMethod paymentMethod, bool isDefault) { var control = LoadControl(string.Format("~/Templates/Sample/Units/CartCheckout/{0}/PaymentMethod.ascx", paymentMethod.SystemKeyword)); _paymentControls.Add(control); HtmlGenericControl div = new HtmlGenericControl("div"); var radioButton = new GlobalRadioButton() { GroupName = "ChoosePayment" }; if (isDefault) { div.Attributes.Add("class", "tab-pane active"); radioButton.Checked = true; } else { div.Attributes.Add("class", "tab-pane fade"); } div.Controls.Add(radioButton); div.Controls.Add(new LiteralControl(string.Format("Use {0}", paymentMethod.Name))); div.Controls.Add(control); PaymentContent.Controls.Add(div); return(div.ClientID.ToString()); }
/* * /// <summary> * /// Makes the address string. * /// </summary> * /// <param name="info">The info.</param> * /// <returns></returns> * private string MakeAddressString(AddressInfo info) * { * if (info == null) * return String.Empty; * string str = String.Format("{0} {1} {2}, {3}, {4}, {5}, {6}, {7}", * info.FirstName, info.MiddleName, info.LastName, info.Address1, info.Address2, * info.City, info.PostalCode, info.Country); * return str.Replace(", ,", ", "); * } * */ /// <summary> /// Sends server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter"></see> object, which writes the content to be rendered on the client. /// </summary> /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter"></see> object that receives the server control content.</param> protected override void Render(HtmlTextWriter writer) { if (PaymentOptionList.Items.Count > 0) { DataListItem item = PaymentOptionList.Items[0]; GlobalRadioButton ctrl = ((GlobalRadioButton)item.FindControl("PaymentOption")); ctrl.Checked = true; } base.Render(writer); }
/// <summary> /// Handles the Validate event of the RadioButtons control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="args">The <see cref="System.Web.UI.WebControls.ServerValidateEventArgs"/> instance containing the event data.</param> protected void RadioButtons_Validate(object source, ServerValidateEventArgs args) { bool bChecked = false; foreach (DataListItem dli in AddressList.Items) { GlobalRadioButton rb = dli.FindControl("rbShipToAddress") as GlobalRadioButton; if (rb != null && rb.Checked) { bChecked = true; break; } } args.IsValid = bChecked || rbShipToNewAddress.Checked; }
public string BindPaymentControls(PaymentMethod paymentMethod, bool isDefault) { var radioButton = new GlobalRadioButton() { GroupName = "ChoosePayment" }; radioButton.Text = string.Format(" Use {0}", paymentMethod.Name.ToHtmlEncode()); radioButton.Checked = isDefault; var control = LoadControl(string.Format("~/Templates/Sample/Units/CartCheckout/{0}/PaymentMethod.ascx", paymentMethod.SystemKeyword)); HtmlGenericControl div = new HtmlGenericControl("div"); div.Attributes.Add("class", isDefault ? "tab-pane active" : "tab-pane fade"); div.Controls.Add(radioButton); div.Controls.Add(control); PaymentContent.Controls.Add(div); return div.ClientID.ToString(); }
protected void rptShippingAddresses_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { if (this._selecetedAddressId == null && e.Item.ItemIndex == 0) { GlobalRadioButton btn = e.Item.FindControl("rbSelectedAddress") as GlobalRadioButton; btn.Checked = true; return; } CustomerAddress address = e.Item.DataItem as CustomerAddress; if (address.Name.Equals(this._selecetedAddressId)) { GlobalRadioButton btn = e.Item.FindControl("rbSelectedAddress") as GlobalRadioButton; btn.Checked = true; } } }
public string BindPaymentControls(PaymentMethod paymentMethod, bool isDefault) { var control = LoadControl(string.Format("~/Templates/Sample/Units/CartCheckout/{0}/PaymentMethod.ascx", paymentMethod.SystemKeyword)); _paymentControls.Add(control); HtmlGenericControl div = new HtmlGenericControl("div"); var radioButton = new GlobalRadioButton() { GroupName = "ChoosePayment" }; if (isDefault) { div.Attributes.Add("class", "tab-pane active"); radioButton.Checked = true; } else { div.Attributes.Add("class", "tab-pane fade"); } div.Controls.Add(radioButton); div.Controls.Add(new LiteralControl(string.Format("Use {0}", paymentMethod.Name))); div.Controls.Add(control); PaymentContent.Controls.Add(div); return div.ClientID.ToString(); }
/// <exclude/> public override string GetDesignTimeHtml() { GlobalRadioButton radio = (GlobalRadioButton)this.ViewControl; String originalText = radio.Text; Boolean noTextSet = String.IsNullOrEmpty(originalText); if (noTextSet) { radio.Text = "[" + radio.ID + "]"; } String result = base.GetDesignTimeHtml(); if (noTextSet) { radio.Text = originalText; } return(result); }
/// <summary> /// Generates the templated column with the /// selection mode /// </summary> private void AnswersDataGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { DataGridItem gridItem = (DataGridItem)e.Item; if (gridItem.ItemType != ListItemType.Footer && gridItem.ItemType != ListItemType.Header) { AnswerTypeData typeData = new AnswerTypes().GetAnswerTypeById(int.Parse(_answers.Answers[gridItem.DataSetIndex].AnswerTypeId.ToString())); gridItem.Cells[3].Text = GetPageResource(typeData.AnswerTypes[0].Description) != null ? GetPageResource(typeData.AnswerTypes[0].Description) : typeData.AnswerTypes[0].Description; int typeMode = int.Parse(DataBinder.Eval(e.Item.DataItem, "TypeMode").ToString()); bool ratePart = (bool)DataBinder.Eval(gridItem.DataItem, "RatePart"); // // Can this answer be selected ? if ((((AnswerTypeMode)typeMode & AnswerTypeMode.Selection) > 0)) { if (MultipleSelection) { CheckBox check = (CheckBox)gridItem.Cells[1].FindControl("DefaultCheckBox"); check.Checked = (bool)DataBinder.Eval(e.Item.DataItem, "Selected"); check.Visible = true; } else { GlobalRadioButton radio = (GlobalRadioButton)gridItem.Cells[1].FindControl("DefaultRadio"); radio.Checked = (bool)DataBinder.Eval(e.Item.DataItem, "Selected"); radio.Visible = true; } if (ratePart) { ((Label)gridItem.FindControl("RatingLabel")).Text = _currentRating.ToString(); _currentRating++; } else { ((Label)gridItem.FindControl("RatingLabel")).Text = "0"; } if (_scoreEnabled) { if (DataBinder.Eval(e.Item.DataItem, "ScorePoint") != null && DataBinder.Eval(e.Item.DataItem, "ScorePoint").ToString().Length > 0) { ((Label)gridItem.FindControl("ScorePoint")).Text = DataBinder.Eval(e.Item.DataItem, "ScorePoint").ToString(); } else { ((Label)gridItem.FindControl("ScorePoint")).Text = "0"; } } } else { gridItem.Cells[1].FindControl("DefaultRadio").Visible = false; gridItem.Cells[1].FindControl("DefaultCheckBox").Visible = false; ((Label)gridItem.FindControl("RatingLabel")).Text = "n/a"; ((Label)gridItem.FindControl("ScorePoint")).Text = "n/a"; } } }