protected void Page_Load(object sender, EventArgs e) { var _db = new Model1(); id = Convert.ToInt32(Request.QueryString["ResourceID"]); riddleRes = (from riddles in _db.riddleresources where riddles.ResourceID == id select riddles).FirstOrDefault(); int blockID = (from resources in _db.resources where resources.ResourceID == id select resources.BlockID).First(); int subjectID = (from blocks in _db.blocks where blocks.BlockID == blockID select blocks.SubjectID).First(); Label label = (Label)Page.FindControlRecursive("name"); label.Text = riddleRes.RiddleName; HtmlSource audioSource = (HtmlSource)Page.FindControlRecursive("audioSource"); audioSource.Src = "Subjects/" + subjectID + "/Audios/" + riddleRes.AudioPath; HtmlAnchor audioLink = (HtmlAnchor)Page.FindControlRecursive("audioLink"); audioLink.HRef = "Subjects/" + subjectID + "/Audios/" + riddleRes.AudioPath; if (riddleRes.ImagePath == "") { Panel container = (Panel)Page.FindControlRecursive("imagePanelContainer"); container.Visible = false; } else { Image img = (Image)Page.FindControlRecursive("imageImage"); img.ImageUrl = "Subjects/" + subjectID + "/Images/" + riddleRes.ImagePath; } if (riddleRes.Text == "") { Panel container = (Panel)Page.FindControlRecursive("OGTextPanelContainer"); container.Visible = false; } else { HtmlGenericControl txt = (HtmlGenericControl)Page.FindControlRecursive("ogtext"); txt.InnerText = riddleRes.Text; } if (riddleRes.TranslatedText == "") { Panel container = (Panel)Page.FindControlRecursive("TransTextPanelContainer"); container.Visible = false; } else { HtmlGenericControl txt = (HtmlGenericControl)Page.FindControlRecursive("transtext"); txt.InnerText = riddleRes.TranslatedText; } HtmlGenericControl answer = (HtmlGenericControl)Page.FindControlRecursive("answer"); answer.InnerText = riddleRes.Answer; }
/// <summary> /// GetItemList /// </summary> /// <param name="url"></param> /// <returns></returns> private List <JToken> GetItemList(string url) { var itemList = new List <string>(); if (!HtmlSource.Trim().StartsWith("{")) { return(new List <JToken>()); } var jObject = JObject.Parse(HtmlSource); var jToken = jObject["listItem"]; //var jArray = JArray.Parse(jObject["listItem"].ToString()); if (jToken == null) { return(new List <JToken>()); } return(new List <JToken>(jToken.Values <JToken>())); }