using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class Controls_PricePointList : WebBlockUserControl { public bool PricePointSelected { get { return (Request.QueryString["price"] != null); } } private string _SelectedPricePoint { get { if (!PricePointSelected) return string.Empty; else return Request.QueryString["price"]; } } private string _PricePoints = string.Empty; public string PricePoints { get { return _PricePoints; } set { _PricePoints = value; } } private string[] pricePoints { get { return _PricePoints.Split(','); } } private string _CssClass = ""; public string CssClass { get { return _CssClass; } set { _CssClass = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) initialize(); } private void initialize() { litPricePoints.Text = "
"; // Set the price point links if (pricePoints.Length > 0 && _PricePoints != string.Empty) { if(_SelectedPricePoint == "under") litPricePoints.Text += "Under $" + pricePoints[0] + "
"; else litPricePoints.Text += "Under $" + pricePoints[0] + "
"; if (pricePoints.Length > 1) for (int i = 0; i < pricePoints.Length - 1; i++) if(_SelectedPricePoint != string.Empty && _SelectedPricePoint != "under" && _SelectedPricePoint != "above" && Convert.ToInt32(_SelectedPricePoint) == i) litPricePoints.Text += "$" + pricePoints[i] + " - $" + pricePoints[i + 1] + "
"; else litPricePoints.Text += "$" + pricePoints[i] + " - $" + pricePoints[i + 1] + "
"; if (_SelectedPricePoint == "above") litPricePoints.Text += "Above $" + pricePoints[pricePoints.Length - 1] + ""; else litPricePoints.Text += "Above $" + pricePoints[pricePoints.Length - 1] + ""; } litPricePoints.Text += "
"; } public double minPrice() { if (!PricePointSelected || _SelectedPricePoint == "under") return 0; else { if (_SelectedPricePoint == "above") return Convert.ToDouble(pricePoints[pricePoints.Length - 1]); else return Convert.ToDouble(pricePoints[Convert.ToInt32(_SelectedPricePoint)]); } } public double maxPrice() { if (!PricePointSelected || _SelectedPricePoint == "above") return -1; else { if (_SelectedPricePoint == "under") return Convert.ToDouble(pricePoints[0]); else return Convert.ToDouble(pricePoints[Convert.ToInt32(_SelectedPricePoint) + 1]); } } }