コード例 #1
0
        private void LoadQuests()
        {
            var res = new MySQLDatabase().Query("getQuestionByTUN",
                                                new Dictionary <string, object>()
            {
                { "@TUN", User.Identity.Name }
            },
                                                true);

            divQuestions.Controls.Clear();

            int?postId = string.IsNullOrEmpty(Request.QueryString["postid"]) ? (int?)null : Convert.ToInt32(Request.QueryString["postid"]);

            foreach (var item in res)
            {
                PostListItem post = LoadControl("~/User Control/PostListItem.ascx") as PostListItem;
                post.PostID = Convert.ToInt32(item["id"]);
                if (postId != null && post.PostID == postId)
                {
                    post.SetActive();
                }
                post.Title      = item["title"];
                post.Badge      = (item["isAnswered"] == "0" ? "new" : "read");
                post.Body       = "- " + item["askedby"];
                post.PostClick += delegate {
                    Response.Redirect(Request.Url.AbsolutePath + "?postid=" + post.PostID);
                };
                divQuestions.Controls.Add(post);
            }
            LoadQuestionDetail(postId);
        }
コード例 #2
0
        private void LoadPostsAccordingToDDL()
        {
            MySQLDatabase db = new MySQLDatabase();
            List <Dictionary <string, string> > res = null;

            if (ddlCatagory.SelectedValue == "All")
            {
                res = db.Query("getAllIdTitle", null, true);
            }
            else
            {
                Dictionary <string, object> dict = new Dictionary <string, object>(1);
                dict.Add("@ptype", int.Parse(ddlCatagory.SelectedValue));
                res = db.Query("getIdTitleByType", dict, true);
            }

            PostList.Controls.Clear();
            int?postId = Convert.ToInt32(Request.QueryString["postid"]);

            foreach (var item in res)
            {
                PostListItem post = LoadControl("~/User Control/PostListItem.ascx") as PostListItem;
                post.Title  = item["title"];
                post.PostID = Convert.ToInt32(item["id"]);
                post.Body   = item["date"];
                if (postId != null && postId == post.PostID)
                {
                    post.SetActive();
                }
                post.PostClick += delegate {
                    Response.Redirect(Request.Url.AbsolutePath + "?postid=" + item["id"] + "&posttype=" + ddlCatagory.SelectedValue, true);
                };
                PostList.Controls.Add(post);
            }
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MySQLDatabase db    = new MySQLDatabase();
            var           res   = db.Query("getAllApplication", null, true);
            var           appid = Request.QueryString["appid"];

            foreach (var item in res)
            {
                PostListItem post = LoadControl("~/User Control/PostListItem.ascx") as PostListItem;
                post.PostID = Convert.ToInt32(item["id"]);
                if (item["id"] == appid)
                {
                    post.SetActive();
                }
                post.Title = item["title"];
                if (item["type"] == "1")
                {
                    post.Badge     = "stu";
                    post.CssClass += " stu";
                }
                else
                {
                    post.Badge     = "tea";
                    post.CssClass += " tea";
                }
                post.Body       = item["date"];
                post.PostClick += delegate { Response.Redirect(Request.Url.AbsolutePath + "?appid=" + post.PostID); };

                Applications.Controls.Add(post);
            }

            if (appid != null)
            {
                var res2 = db.Query("getResponseByAId",
                                    new Dictionary <string, object>()
                {
                    { "@AId", Convert.ToInt32(appid) }
                },
                                    true);
                foreach (var item in res2)
                {
                    PostListItem post = LoadControl("~/User Control/PostListItem.ascx") as PostListItem;
                    post.PostID = Convert.ToInt32(item["id"]);
                    post.Title  = item["name"];
                    post.Body   = item["email"];
                    //post.PostClick += delegate { Response.Redirect; };
                    post.OnClientClick += "window.open('" + ("Response?resid=" + post.PostID) + "','_blank')";
                    Responses.Controls.Add(post);
                }
            }
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string dir  = Request.QueryString["album"];
            string root = Server.MapPath("~");

            string[] albums = Directory.GetDirectories(root + "/Albums");
            divAlbum.Controls.Clear();
            foreach (var album in albums)
            {
                PostListItem post = LoadControl("~/User Control/PostListItem.ascx") as PostListItem;
                post.Title      = album.Split('\\').Last();
                post.PostClick += delegate { Response.Redirect("~/Admin/Gallery?album=" + post.Title); };
                if (dir != null && dir == post.Title)
                {
                    post.SetActive();
                }
                divAlbum.Controls.Add(post);
            }
        }