protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { User aUser = (User)Session["aUser"]; string id = Request.QueryString["id"]; PostManager anPostManager=new PostManager(); Post anPost= anPostManager.GetPostById(id); string edit=""; postitle.InnerHtml = anPost.PostTitle; if (aUser!=null && aUser.UserId==anPost.userId) { edit = "<a href='submit-post.aspx?id=" + anPost.PostId + "'> Edit</a>"; } string postdes = "<strong>Author:</strong><a href='author-profile.aspx?id=" + anPost.userId + "'>" + anPost.UserFullName + "</a>|<strong>Post View: </strong>" + anPost.ViewCount + " " + edit + " <p>" + anPost.PostDescreption + "</p>"; postcontent.InnerHtml = postdes; if (Session["aUser"] != null) { Login1.Visible = false; login.InnerText = "Hi " + aUser.UserFullName; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Model.User anUser = (User) Session["aUser"]; string queryst = Request.QueryString["id"]; if (anUser == null) { Response.Redirect("LoginPage.aspx"); } else if (queryst != null) { PostManager anPostManager = new PostManager(); Post aPost = anPostManager.GetPostById(queryst); if (aPost.userId == anUser.UserId) { titleTexbox.Text = aPost.PostTitle; edit.InnerText = aPost.PostDescreption; if (aPost.PostIsPublished) { DropDownList1.SelectedItem.Text = "Published"; DropDownList1.SelectedItem.Value = "True"; } else { DropDownList1.SelectedItem.Text = "UnPublished"; DropDownList1.SelectedItem.Value = "false"; } } else { Response.Redirect("LoginPage.aspx"); } } } }