protected void PopulateData(string code) { string strHTML = string.Empty, path_image = string.Empty, path_image1 = string.Empty, NavigateUrl = string.Empty, NavigateUrl1 = string.Empty; ArticleController article_obj = new ArticleController(); DataTable dt = article_obj.GetListByCode(code); if (dt.Rows.Count > 1) { Uri requestUri = Context.Request.Url; string baseUrl = requestUri.Scheme + Uri.SchemeDelimiter + requestUri.Host + (requestUri.IsDefaultPort ? "" : ":" + requestUri.Port); int total = 0; if (dt.Rows.Count / 2 == 0) total = dt.Rows.Count; else total = dt.Rows.Count - 1; for (int i = 0; i < total; i += 2) { if (dt.Rows[i]["Frontimage"].ToString() != "") path_image = baseUrl + "/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/article_images/front_images/" + dt.Rows[i]["Frontimage"].ToString(); else path_image = baseUrl + "/images/no_image.jpg"; if (dt.Rows[i + 1]["Frontimage"].ToString() != "") path_image1 = baseUrl + "/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/article_images/front_images/" + dt.Rows[i + 1]["Frontimage"].ToString(); else path_image1 = baseUrl + "/images/no_image.jpg"; if (dt.Rows[i]["NavigateUrl"].ToString() != "") NavigateUrl = dt.Rows[i]["NavigateUrl"].ToString(); else NavigateUrl = "#"; if (dt.Rows[i + 1]["NavigateUrl"].ToString() != "") NavigateUrl1 = dt.Rows[i + 1]["NavigateUrl"].ToString(); else NavigateUrl1 = "#"; strHTML += "<div class=\"item\">" + "<div class=\"col_odd\" style=\"float:left; padding: 3px; border:1px solid #CCCCCC; margin-right: 5px;\">" + "<a href='" + NavigateUrl + "'><img src=\"" + path_image + "\" width=\"120px\" height=\"110px\" alt=\"" + dt.Rows[i]["Alias"].ToString() + "\" /></a>" + "</div>" + "<div class=\"col_even\" style=\"float:left; padding: 3px; border:1px solid #CCCCCC;\">" + "<a href='" + NavigateUrl1 + "'><img src=\"" + path_image1 + "\" width=\"120px\" height=\"110px\" alt=\"" + dt.Rows[i + 1]["Alias"].ToString() + "\" /></a>" + "</div>" + "</div>"; } } else strHTML = "<div class=\"item\">Dữ liệu không hợp lý</div>"; LiteralContents.Text = strHTML; }
protected void PopulateData(string code) { string strHTML = string.Empty, path_image = string.Empty, path_image1 = string.Empty, NavigateUrl = string.Empty, NavigateUrl1 = string.Empty; ArticleController article_obj = new ArticleController(); DataTable dt = article_obj.GetListByCode(code); if (dt.Rows.Count > 1) { Uri requestUri = Context.Request.Url; string baseUrl = requestUri.Scheme + Uri.SchemeDelimiter + requestUri.Host + (requestUri.IsDefaultPort ? "" : ":" + requestUri.Port); int total = 0; if (dt.Rows.Count / 2 == 0) total = dt.Rows.Count; else total = dt.Rows.Count - 1; for (int i = 0; i < total; i += 2) { if (dt.Rows[i]["Frontimage"].ToString() != "") path_image = baseUrl + "/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/article_images/front_images/" + dt.Rows[i]["Frontimage"].ToString(); else path_image = baseUrl + "/images/no_image.jpg"; if (dt.Rows[i + 1]["Frontimage"].ToString() != "") path_image1 = baseUrl + "/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/article_images/front_images/" + dt.Rows[i + 1]["Frontimage"].ToString(); else path_image1 = baseUrl + "/images/no_image.jpg"; if (dt.Rows[i]["NavigateUrl"].ToString() != "") NavigateUrl = dt.Rows[i]["NavigateUrl"].ToString(); else NavigateUrl = "#"; if (dt.Rows[i + 1]["NavigateUrl"].ToString() != "") NavigateUrl1 = dt.Rows[i + 1]["NavigateUrl"].ToString(); else NavigateUrl1 = "#"; strHTML += "<li class=\"item\">" + "<a class=\"col_odd\" href='" + NavigateUrl + "'><img width='120px' height=120px' src=\"" + path_image + "\" alt=\"" + dt.Rows[i]["Alias"].ToString() + "\" /></a>" + "<a class=\"col_even\" href='" + NavigateUrl1 + "'><img width='120px' height=120px' src=\"" + path_image1 + "\" alt=\"" + dt.Rows[i + 1]["Alias"].ToString() + "\" /></a>" + "</li>"; } } else strHTML = "<li class=\"item\">Dữ liệu không hợp lý</li>"; scroller.InnerHtml = "<ul id=\"scroller_vticker\" class=\"ticker\">" + strHTML + "</ul>"; }
protected void LoadSlideData(string code) { string strHTML = string.Empty, Alias = string.Empty, Slide = string.Empty, FrontImagePath = string.Empty, Headline = string.Empty, NavigateUrl= string.Empty; string path_front_image = "/user_files/images/article_images/front_images/"; ArticleController article_obj = new ArticleController(); DataTable dt = article_obj.GetListByCode(code); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Alias = dt.Rows[i]["Alias"].ToString(); if (!string.IsNullOrEmpty(dt.Rows[i]["NavigateUrl"].ToString())) NavigateUrl = dt.Rows[i]["NavigateUrl"].ToString(); else NavigateUrl = "#"; if (!string.IsNullOrEmpty(dt.Rows[i]["FrontImage"].ToString())) FrontImagePath = path_front_image + dt.Rows[i]["FrontImage"].ToString(); else FrontImagePath = "/images/no_image.jpg"; if(!string.IsNullOrEmpty(dt.Rows[i]["Headline"].ToString())) { if (dt.Rows[i]["Headline"].ToString().Length > 20) Headline = dt.Rows[i]["Headline"].ToString().Substring(0, 20); else Headline = dt.Rows[i]["Headline"].ToString(); Slide += "<div>" + "<a href='" + NavigateUrl + "'>" + "<img height='94' width='120' alt=\"" + Alias + "\" src='" + FrontImagePath + "' /><br />" + "<span class=\"thumbnail-text\">" + Headline + "</span></a>" + "</div>"; }else{ Slide += "<div>" + "<a href='" + NavigateUrl + "'>" + "<img height='94' width='120' alt=\"" + Alias + "\" src='" + FrontImagePath + "' /></a>" + "</div>"; } } strHTML = "<div id=\"carouselSider\">" + Slide + "</div>"; } carouselSider.InnerHtml = strHTML; }
protected void PopulateArticle2DDL() { string code = ddlCategory.SelectedValue; ArticleController article_obj = new ArticleController(); DataTable dt = article_obj.GetListByCode(code); ddlArticles.Items.Clear(); if (dt.Rows.Count > 0) { ddlArticles.DataSource = dt; ddlArticles.DataTextField = "Title"; ddlArticles.DataValueField = "ArticleId"; ddlArticles.DataBind(); } else { ddlArticles.Items.Insert(0, new ListItem("- Chọn -", "0")); ddlArticles.SelectedIndex = 0; ddlArticles.DataBind(); } ddlArticles.AutoPostBack = true; }