Exemplo n.º 1
0
        public IEncodedString RegionSelect(NBrightInfo info, String xpath, String countryCode, String attributes = "", Boolean allowEmpty = true)
        {
            if (countryCode == "")
            {
                // get the countrycode if already updated
                countryCode = info.GetXmlProperty(xpath.Replace("region", "country"));
            }

            var rtnList = NBrightBuyUtils.GetRegionList(countryCode);

            if (rtnList != null && rtnList.Count > 0)
            {
                // we have a list, so do a dropdownlist
                if (attributes.StartsWith("ResourceKey:"))
                {
                    attributes = ResourceKey(attributes.Replace("ResourceKey:", "")).ToString();
                }

                var strOut = "";

                var upd = getUpdateAttr(xpath, attributes);
                var id  = getIdFromXpath(xpath);
                strOut = "<select id='" + id + "' " + upd + " " + attributes + ">";
                var s = "";
                if (allowEmpty)
                {
                    strOut += "    <option value=''></option>";
                }
                foreach (var tItem in rtnList)
                {
                    if (info.GetXmlProperty(xpath) == tItem.Key.ToString())
                    {
                        s = "selected";
                    }
                    else
                    {
                        s = "";
                    }
                    strOut += "    <option value='" + tItem.Key.ToString() + "' " + s + ">" + tItem.Value + "</option>";
                }
                strOut += "</select>";
                return(new RawString(strOut));
            }
            else
            {
                // no list so output textbox
                xpath = xpath.Replace("dropdownlist", "textbox");
                return(NBrightTextBox(info, xpath, attributes, ""));
            }
        }