Beispiel #1
0
        void Bind()//绑定数据
        {
            if (Request.QueryString["themeId"] != null)
            {
                if (Request["path"] != null)
                {
                    lbtnPath.Text = Convert.ToString(Request["path"]).Trim();//设置上一级的路径
                }
                Theme theme = new Theme()
                {
                    ThemeId = Convert.ToString(Request.QueryString["themeId"])
                };
                if (theme.IsError)
                {
                    Msg = "参数格式错误";
                    printMsgToClient();
                    return;
                }
                #region 动态生成主题
                dt = ThemeManagement.SelectByThemeId(theme.ThemeId);
                if (dt.Rows.Count == 1)
                {
                    ThemeId.Text                = "【" + Convert.ToString(dt.Rows[0]["theme_id"]) + "】" + Convert.ToString(dt.Rows[0]["title"]);//标题
                    MemberId.InnerHtml          = Convert.ToString(dt.Rows[0]["creator"]);
                    MemberId.HRef               = "~/Others.aspx?memberId=" + Convert.ToString(dt.Rows[0]["creator"]);
                    xp.Attributes["style"]      = "background-image:url(" + SomeMethod.GetLevelPicPath(dt.Rows[0]["xp"]) + ");";     //等级图标
                    text.InnerHtml              = Server.UrlDecode(Convert.ToString(dt.Rows[0]["theme_text"]));                      //主题内容
                    lblPublishiTime.Text        = "发表于:" + Convert.ToString(dt.Rows[0]["publish_time"]);                             //发布时间
                    picture.Attributes["style"] = "background-image:url(" + SomeMethod.GetUserPicPath(dt.Rows[0]["picture"]) + ");"; //头像

                    UserName.InnerHtml = Convert.ToString(dt.Rows[0]["name"]);                                                       //查找用户名
                }
                else
                {
                    Msg = "主题不存在";
                    printMsgToClient();
                    return;
                }
                #endregion
                #region 动态生成评论
                dt = CriticismManagement.SelectByThemeId(theme.ThemeId);
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    #region 生成一条评论并显示
                    //生成如下html代码
                    //<div class="tr">
                    //<div class="left">
                    //    <img class="pic" src="头像路径">
                    //    <div class="person">
                    //        <a href="#">账号</a>
                    //        <a href="javascript:__doPostBack('addConcern','');" onclick="concernClick()" runat="server" onserverclick="Unnamed_ServerClick"><img src="Image/ThemeDisplay/关注.png" style="width: 40px; height: 20px;" /></a>
                    //    </div>
                    //    <div>
                    //        <div class="name" style="text-align: left;">用户名</div>
                    //        <img class="lv" src="等级图片路径"/>
                    //    </div>
                    //</div>
                    //<div class="right">
                    //    <div class="text"></div>
                    //    <div class="operate">
                    //        <input type="hidden" value="评论的编号" />
                    //        <div class="lblPublishiTime">发布时间</div>
                    //        <a class="pic1" href="javascript:void(0)" onclick="reportClick()"><img src="Image/ThemeDisplay/举报.png"/></a>
                    //        <a class="pic2" href="javascript:void(0)" onclick="criticismClick()"><img src="Image/ThemeDisplay/评论.png"/></a>
                    //    </div>
                    //</div>
                    //</div>

                    sb.Append("<div class=\"tr\">");
                    sb.Append("<div class=\"left\"><img class=\"pic\" src=\"");
                    sb.Append(SomeMethod.GetUserPicPath(dt.Rows[i]["picture"]));                    //头像路径
                    sb.Append("\"/><div class=\"person\"><a href=\"");
                    sb.Append("Others.aspx?memberId=" + Convert.ToString(dt.Rows[0]["member_id"])); //账号链接路径
                    sb.Append("\">");
                    sb.Append(dt.Rows[i]["member_id"]);                                             //账号
                    sb.Append("</a><a href=\"javascript:__doPostBack('addConcern','');\" onclick=\"concernClick()\" runat=\"server\" onserverclick=\"Unnamed_ServerClick\"><img src=\"Image/ThemeDisplay/关注.png\" style=\"width: 40px; height: 20px;\" /></a></div><div><div class=\"name\" style=\"text-align: left;\">");
                    sb.Append(Convert.ToString(dt.Rows[0]["name"]));                                //用户名
                    sb.Append("</div><img class=\"lv\" src=\"");
                    sb.Append(SomeMethod.GetLevelPicPath(dt.Rows[i]["xp"]));                        //等级图片路径
                    sb.Append("\"/></div></div><div class=\"right\"><div class=\"text\"><p>");
                    sb.Append(Server.UrlDecode(Convert.ToString(dt.Rows[i]["criticism_text"])));    //评论
                    sb.Append("</p></div><div class=\"operate\"><input type=\"hidden\" value=\"");
                    sb.Append(dt.Rows[i]["criticism_id"]);                                          //评论编号
                    sb.Append("\" /><div class=\"lblPublishiTime\">发表于:");
                    sb.Append(dt.Rows[i]["publish_time"]);                                          //发布时间
                    sb.Append("</div><a class=\"pic1\" href=\"javascript:void(0)\" onclick=\"reportClick()\"><img src=\"Image/ThemeDisplay/举报.png\" style=\"width: 30px; height: 30px\"/></a><a href=\"javascript:void(0)\" onclick=\"criticismClick()\"><img class=\"pic2\" src=\"Image/ThemeDisplay/评论.png\" style=\"width: 30px; height: 30px\" /></a></div></div></div>");
                    #endregion
                }
                criticisms.InnerHtml = sb.ToString();
                #endregion
            }
        }