protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["id"] != null)
     {
         string id = Request.QueryString["id"];
         food = foodBLL.Query(id);
         if (food != null)
         {
             author = userBLL.QueryInfoByID(food.UploaderID);
             if (author != null)
             {
                 this.titleFood.InnerHtml    = food.Title;
                 this.imgFood.Src            = "Static/Image/Cover/cover_" + food.Cover;
                 this.textFood.InnerHtml     = food.Contents;
                 this.imgFace.Src            = "Static/Image/Face/face_avatar1_" + author.FacePath + ".jpg";
                 this.textEmail.InnerHtml    = author.Email;
                 this.textNickName.InnerHtml = author.NickName;
             }
             else
             {
                 LayerShow.Alert(this, "内部错误,无效的上传者ID", "Index.aspx");
             }
         }
         else
         {
             E : \ web设计 \ FoodStory \ FoodStory \ Static \ CSS \ bootstrap - theme.min.css
             LayerShow.Alert(this, "无法找到该页面", "Index.aspx");
         }
     }
     else
     {
         Response.Redirect("~/Index.aspx");
     }
 }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["userName"] != null)
            {
                FoodBLL   foodBLL     = new FoodBLL();
                UserBLL   userBLL     = new UserBLL();
                User      userMe      = userBLL.QueryInfo(Session["userName"].ToString());
                DataTable dtFarvorite = userBLL.FarvoriteTable(userMe.ID);
                for (int i = 0; i < dtFarvorite.Rows.Count; i++)
                {
                    Food food = foodBLL.Query(dtFarvorite.Rows[i]["FoodID"].ToString());

                    User   user     = userBLL.QueryInfoByID(food.UploaderID);
                    string facePath = "";
                    if (user != null && user.FacePath != "")
                    {
                        facePath = "Static/Image/Face/face_avatar2_" + user.FacePath + ".jpg";
                    }
                    else
                    {
                        facePath = "Static/Image/face_avatar_default.png";
                    }
                    string foodTitle = food.Title;
                    if (Encoding.Default.GetByteCount(foodTitle) > 18)
                    {
                        foodTitle = foodTitle.Substring(0, 17) + "…";
                    }
                    string foodUrl = "Foods.aspx?id=" + food.ID;
                    //构造html
                    this.masonryDiv.InnerHtml += "<div class=\"item thumbnail\">"
                                                 + "<img class=\"img-rounded\" src=\"Static/Image/loading.gif\" data-original=\"Static/Image/Cover/cover_"
                                                 + food.Cover
                                                 + "\" >"
                                                 + "<hr />"
                                                 + "<div class=\"container-fluid\" style=\"margin-top: 5px;\">"
                                                 + "<div class=\"row-fluid\" >"
                                                 + "<div class=\"col-md-2 nop\">" + "<img class=\"img-circle img-face\" src=\"" + facePath + "\" title=\""
                                                 + user.NickName + "\" >" + "</div>"
                                                 + "<div class=\"col-md-3 nop food-title\"><p>分享的:</p></div>"
                                                 + "<div class=\"col-md-7 nop food-title\"><a href=\"" + foodUrl + "\">" + foodTitle + "</a></div>"
                                                 + "</div></div>"
                                                 + "</div>\r\n";
                }
            }
            else
            {
                Response.Redirect("Index.aspx");
            }
        }