using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace FineUIPro.Web { public partial class ajax : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LoadData(); } } private void LoadData() { string content = ReadFile("~/config/ajax_properties.txt"); Dictionary allControls = new Dictionary(); List publicControls = new List(); JArray ja = JArray.Parse(content); foreach (JObject jo in ja) { if (jo.Value("public")) // .getBool("public")) { publicControls.Add(jo.Value("name")); //jo.getString("name")); } allControls.Add(jo.Value("name"), jo); //jo.getString("name"), jo); } publicControls.Sort(); StringBuilder sb = new StringBuilder(); sb.Append("
    "); for (int i = 0, count = publicControls.Count; i < count; i++) { string name = publicControls[i]; sb.Append("
  • "); sb.AppendFormat("
    "); sb.AppendFormat("
    {0}
    ", name); // 计算控件name的所有AJAX属性 List ajaxProperties = new List(); string parentControlName = name; do { JObject control = allControls[parentControlName]; foreach (string property in control.Value("ajax")) // .getJSONArray("ajax").getArrayList()) { if (!ajaxProperties.Contains(property)) { ajaxProperties.Add(property); } } parentControlName = control.Value("parent"); //.getString("parent"); } while (!String.IsNullOrEmpty(parentControlName)); ajaxProperties.Sort(); sb.Append("
    "); sb.Append("
      "); foreach (string property in ajaxProperties) { sb.AppendFormat("
    • {0}
    • ", property); } sb.Append("
    "); sb.Append("
    "); sb.Append("
    "); sb.Append("
  • "); //if ((i + 1) % 6 == 0) //{ // sb.Append(""); //} } sb.Append("
"); litResult.Text = sb.ToString(); } private string ReadFile(string filePath) { string content = String.Empty; using (System.IO.StreamReader sr = new System.IO.StreamReader(Server.MapPath(filePath))) { content = sr.ReadToEnd(); } return content; } } }