protected void lbtn_Edit_Post_Click(object sender, EventArgs e) { _view_stage = "view_edit"; ViewState["ViewStage"] = _view_stage; MultiView_PostView.SetActiveView(View_Edit); if (!DataEval.IsEmptyQuery(Request["NexusBlogPostID"])) { Lib.BlogMgr myBlogMgr = new Lib.BlogMgr(); Lib.Blog_Post myBlog_Post = myBlogMgr.Get_Blog_Post(Request["NexusBlogPostID"]); // Initiate Post form default setting RadEditor_BlogContent.ToolsFile = "~/App_Data/Editor/BasicTools.xml"; #region Bind Data to droplist // Enable user edit mode //Gets your enum names and adds it to a string array Array enumNames = Enum.GetValues(typeof(Lib.Post_Status)); //Creates an ArrayList ArrayList myPost_Statuses = new ArrayList(); //Loop through your string array and poppulates the ArrayList foreach (Lib.Post_Status myPost_Status in enumNames) { myPost_Statuses.Add(new { Value = StringEnum.GetStringValue(myPost_Status), Name = myPost_Status.ToString() }); } //Bind the ArrayList to your DropDownList droplist_PostStatus.DataSource = myPost_Statuses; droplist_PostStatus.DataTextField = "Name"; droplist_PostStatus.DataValueField = "Value"; droplist_PostStatus.DataBind(); #endregion // Init Form data tbx_Title.Text = myBlog_Post.Post_Title; RadEditor_BlogContent.Content = myBlog_Post.Post_Content; droplist_PostStatus.SelectedValue = myBlog_Post.Post_Status.ToString(); tbx_Password.Text = myBlog_Post.Post_Password; RadDateTimePicker_PostDate.SelectedDate = Convert.ToDateTime(myBlog_Post.Post_Date); } else { Control_Init(); } }
private void Control_Init() { if (DataEval.IsEmptyQuery(_postviewid)) { MultiView_PostView.SetActiveView(View_New); } else { if (Request.QueryString["PageLink"] == "Disable") { lbtn_Edit_Post.Enabled = false; btn_PostComment.Enabled = false; } MultiView_PostView.SetActiveView(View_Post); // Init Comment Form RadEditor_Comment.ToolsFile = "~/App_Data/Editor/BasicTools.xml"; RadEditor_Comment.EditModes = Telerik.Web.UI.EditModes.Design | Telerik.Web.UI.EditModes.Preview; // Fillup Post Content lbl_Title.Text = "Demo Title..."; lbl_Post_Date.Text = DateTime.Now.ToShortDateString(); lbl_UserName.Text = "Demo User Name"; Literal_Content.Text = "<p>Demo Content...</p>"; lbl_Post_ModifyDate.Text = DateTime.Now.ToString(); lbl_Comment_Count.Text = "0"; // Add Social button PlaceHolder_SocialNetwork.Controls.Clear(); HyperLink myHyperLink = new HyperLink(); myHyperLink.ImageUrl = "~/App_Control_Style/Nexus_mBlog/SocialBookmark/Facebook_24.png"; PlaceHolder_SocialNetwork.Controls.Add(myHyperLink); } }
private void Control_Init() { if (DataEval.IsEmptyQuery(_postviewid)) { MultiView_PostView.SetActiveView(View_New); } else { if (Request.QueryString["PageLink"] == "Disable") { lbtn_Edit_Post.Enabled = false; lbtn_BlogPostsURL.Enabled = false; btn_PostComment.Enabled = false; } if (_view_stage == "view_edit") { MultiView_PostView.SetActiveView(View_Edit); } else { MultiView_PostView.SetActiveView(View_Post); _view_stage = "view_post"; ViewState["ViewStage"] = _view_stage; // Init Comment Form RadEditor_Comment.ToolsFile = "~/App_Data/Editor/BasicTools.xml"; RadEditor_Comment.EditModes = Telerik.Web.UI.EditModes.Design | Telerik.Web.UI.EditModes.Preview; RadEditor_Comment.Content = ""; if (!DataEval.IsEmptyQuery(Request["NexusBlogPostID"])) { Lib.BlogMgr myBlogMgr = new Lib.BlogMgr(); Lib.Blog_Post myBlog_Post = myBlogMgr.Get_Blog_Post(Request["NexusBlogPostID"]); if (Security.Users.UserStatus.Validate_Ownership(this.Page, myBlog_Post.Ownership_UserID) || Security.Users.UserStatus.Validate_PageAuth_Modify(this.Page)) { lbtn_Edit_Post.Visible = true; } else { lbtn_Edit_Post.Visible = false; } // Page Title if (_ispagetitle) { Page.Title = myBlog_Post.Post_Title; } // Fillup Post Content lbl_Title.Text = myBlog_Post.Post_Title; lbl_Post_Date.Text = myBlog_Post.Post_Date_Short; lbl_UserName.Text = myBlog_Post.UserName; Literal_Content.Text = myBlog_Post.Post_Content; lbl_Post_ModifyDate.Text = myBlog_Post.Post_ModifyDate; lbl_Comment_Count.Text = myBlog_Post.Comment_Count; // Add Social button PlaceHolder_SocialNetwork.Controls.Clear(); string _facebook = string.Format("http://www.facebook.com/sharer.php?u={0}&t={1}", Server.UrlEncode(Request.Url.ToString()), Server.UrlEncode(myBlog_Post.Post_Title)); HyperLink myHyperLink = new HyperLink(); myHyperLink.NavigateUrl = _facebook; myHyperLink.Target = "_blank"; myHyperLink.ImageUrl = "~/App_Control_Style/Nexus_mBlog/SocialBookmark/Facebook_24.png"; PlaceHolder_SocialNetwork.Controls.Add(myHyperLink); // Load User Name and Disable Guest Comment string _current_username = Security.Users.UserStatus.Current_UserName(this.Page); if (_current_username == "Guest") { if (_isguestcomment) { btn_PostComment.Enabled = true; } else { btn_PostComment.Enabled = false; } tbx_Comment_UserName.Enabled = true; } else { tbx_Comment_UserName.Text = _current_username; tbx_Comment_UserName.Enabled = false; } // Bind Post Comment ListView_Comment.DataSource = myBlogMgr.Get_Blog_Comments(Request["NexusBlogPostID"], "1"); ListView_Comment.DataKeyNames = new string[] { "CommentID" }; ListView_Comment.DataBind(); DataPager_PostView.PageSize = _numberperpage; } else { // No Post ID lbtn_Edit_Post.Visible = false; btn_PostComment.Visible = false; } } } }
private void Control_Init() { if (DataEval.IsEmptyQuery(_postviewid)) { MultiView_PostView.SetActiveView(View_New); } else { if (Request.QueryString["PageLink"] == "Disable") { lbtn_Edit_Post.Enabled = false; btn_PostComment.Enabled = false; } MultiView_PostView.SetActiveView(View_Post); // Init Comment Form RadEditor_Comment.ToolsFile = "~/App_Data/Editor/BasicTools.xml"; RadEditor_Comment.EditModes = Telerik.Web.UI.EditModes.Design | Telerik.Web.UI.EditModes.Preview; // Fillup Post Content if (!DataEval.IsEmptyQuery(Request["NexusBlogPostID"])) { Lib.BlogMgr myBlogMgr = new Lib.BlogMgr(); Lib.Blog_Post myBlog_Post = myBlogMgr.Get_Blog_Post(Request["NexusBlogPostID"]); List <Blog_Post> myPostViews = new List <Blog_Post>(); myPostViews.Add(myBlog_Post); FormView_PostView.DataSource = myPostViews; FormView_PostView.DataKeyNames = new string[] { "PostID" }; Core.Tools.AppItemTemplates myPostView_ItemTemplate = new Core.Tools.AppItemTemplates(); switch (_postview_itemtemplate) { case "Default": myPostView_ItemTemplate.ItemTemplatePath = "~/App_Control_Style/Nexus_Blog/Templates/PostView_Default.ascx"; break; case "Custom": myPostView_ItemTemplate.ItemTemplatePath = _postview_itemtemplateurl; break; default: myPostView_ItemTemplate.ItemTemplatePath = "~/App_Control_Style/Nexus_Blog/Templates/PostView_Default.ascx"; break; } FormView_PostView.ItemTemplate = Page.LoadTemplate(myPostView_ItemTemplate.ItemTemplatePath); try { FormView_PostView.DataBind(); } catch { // Load Template Failed } //lbl_Title.Text = "Demo Title..."; //lbl_Post_Date.Text = DateTime.Now.ToShortDateString(); //lbl_UserName.Text = "Demo User Name"; //Literal_Content.Text = "<p>Demo Content...</p>"; //lbl_Post_ModifyDate.Text = DateTime.Now.ToString(); //lbl_Comment_Count.Text = "0"; //// Add Social button //PlaceHolder_SocialNetwork.Controls.Clear(); //HyperLink myHyperLink = new HyperLink(); //myHyperLink.ImageUrl = "~/App_Control_Style/Nexus_Blog/SocialBookmark/Facebook_24.png"; //PlaceHolder_SocialNetwork.Controls.Add(myHyperLink); } else { // No Post ID lbtn_Edit_Post.Visible = false; btn_PostComment.Visible = false; } } }
private void Control_Init() { if (DataEval.IsEmptyQuery(_postviewid)) { MultiView_PostView.SetActiveView(View_New); } else { if (Request.QueryString["PageLink"] == "Disable") { lbtn_Edit_Post.Enabled = false; btn_PostComment.Enabled = false; } if (_view_stage == "view_edit") { MultiView_PostView.SetActiveView(View_Edit); } else { MultiView_PostView.SetActiveView(View_Post); _view_stage = "view_post"; ViewState["ViewStage"] = _view_stage; // Init Comment Form RadEditor_Comment.ToolsFile = "~/App_Data/Editor/BasicTools.xml"; RadEditor_Comment.EditModes = Telerik.Web.UI.EditModes.Design | Telerik.Web.UI.EditModes.Preview; if (!DataEval.IsEmptyQuery(Request["NexusBlogPostID"])) { Lib.BlogMgr myBlogMgr = new Lib.BlogMgr(); Lib.Blog_Post myBlog_Post = myBlogMgr.Get_Blog_Post(Request["NexusBlogPostID"]); if (Security.Users.UserStatus.Validate_Ownership(this.Page, myBlog_Post.Ownership_UserID) || Security.Users.UserStatus.Validate_PageAuth_Modify(this.Page)) { lbtn_Edit_Post.Visible = true; } else { lbtn_Edit_Post.Visible = false; } // Page Title if (_ispagetitle) { Page.Title = myBlog_Post.Post_Title; } // Fillup Post Content List <Blog_Post> myPostViews = new List <Blog_Post>(); myPostViews.Add(myBlog_Post); FormView_PostView.DataSource = myPostViews; FormView_PostView.DataKeyNames = new string[] { "PostID" }; Core.Tools.AppItemTemplates myPostView_ItemTemplate = new Core.Tools.AppItemTemplates(); switch (_postview_itemtemplate) { case "Default": myPostView_ItemTemplate.ItemTemplatePath = "~/App_Control_Style/Nexus_Blog/Templates/PostView_Default.ascx"; break; case "Custom": myPostView_ItemTemplate.ItemTemplatePath = _postview_itemtemplateurl; break; default: myPostView_ItemTemplate.ItemTemplatePath = "~/App_Control_Style/Nexus_Blog/Templates/PostView_Default.ascx"; break; } FormView_PostView.ItemTemplate = Page.LoadTemplate(myPostView_ItemTemplate.ItemTemplatePath); try { FormView_PostView.DataBind(); } catch { // Load Template Failed } //lbl_Title.Text = myBlog_Post.Post_Title; //lbl_Post_Date.Text = myBlog_Post.Post_Date_Short; //lbl_UserName.Text = myBlog_Post.UserName; //Literal_Content.Text = myBlog_Post.Post_Content; //lbl_Post_ModifyDate.Text = myBlog_Post.Post_ModifyDate; //lbl_Comment_Count.Text = myBlog_Post.Comment_Count; //// Add Social button //PlaceHolder_SocialNetwork.Controls.Clear(); //string _facebook = string.Format("http://www.facebook.com/sharer.php?u={0}&t={1}", Server.UrlEncode(Request.Url.ToString()), Server.UrlEncode(myBlog_Post.Post_Title)); //HyperLink myHyperLink = new HyperLink(); //myHyperLink.NavigateUrl = _facebook; //myHyperLink.Target = "_blank"; //myHyperLink.ImageUrl = "~/App_Control_Style/Nexus_Blog/SocialBookmark/Facebook_24.png"; //PlaceHolder_SocialNetwork.Controls.Add(myHyperLink); // Load User Name and Disable Guest Comment string _current_username = Security.Users.UserStatus.Current_UserName(this.Page); if (_current_username == "Guest") { if (_isguestcomment) { btn_PostComment.Enabled = true; } else { btn_PostComment.Enabled = false; } tbx_Comment_UserName.Enabled = true; Panel_Comment_Contact.Visible = false; } else { tbx_Comment_UserName.Text = _current_username; tbx_Comment_UserName.Enabled = false; Panel_Comment_Contact.Visible = true; } // Bind Post Comment ListView_Comment.DataSource = myBlogMgr.Get_Blog_Comments(Request["NexusBlogPostID"], "1"); ListView_Comment.DataKeyNames = new string[] { "CommentID" }; Core.Tools.AppItemTemplates myComment_ItemTemplate = new Core.Tools.AppItemTemplates(); switch (_comment_itemtemplate) { case "Default": myComment_ItemTemplate.ItemTemplatePath = "~/App_Control_Style/Nexus_Blog/Templates/PostComment_Default.ascx"; break; case "Custom": myComment_ItemTemplate.ItemTemplatePath = _comment_itemtemplateurl; break; default: myComment_ItemTemplate.ItemTemplatePath = "~/App_Control_Style/Nexus_Blog/Templates/PostComment_Default.ascx"; break; } myComment_ItemTemplate.Set_Separator(""); myComment_ItemTemplate.Set_DataEmpty(""); ListView_Comment.ItemTemplate = Page.LoadTemplate(myComment_ItemTemplate.ItemTemplatePath); ListView_Comment.AlternatingItemTemplate = Page.LoadTemplate(myComment_ItemTemplate.AltPath); if (!DataEval.IsEmptyQuery(myComment_ItemTemplate.Separator)) { ListView_Comment.ItemSeparatorTemplate = Page.LoadTemplate(myComment_ItemTemplate.Separator); } if (!DataEval.IsEmptyQuery(myComment_ItemTemplate.DataEmpty)) { ListView_Comment.EmptyDataTemplate = Page.LoadTemplate(myComment_ItemTemplate.DataEmpty); } try { ListView_Comment.DataBind(); } catch { // Load Template Failed } DataPager_PostView.PageSize = _numberperpage; DataPager_PostView.Visible = _enable_pager; } else { // No Post ID lbtn_Edit_Post.Visible = false; btn_PostComment.Visible = false; } } } }