📄 shownews.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL.System;
using Common.Entities;
public partial class ShowNews : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int articleId = int.Parse(Request.QueryString["articleId"]);
ShowContent(articleId);
//将新闻ID添加到隐藏域中
hidArticleID.Value = articleId.ToString();
}
}
//显示内容
private void ShowContent(int articleId)
{
ArticleSystem articleSystem = new ArticleSystem();
ArticleData articleData = articleSystem.GetModel(articleId);
this.lblClassName.Text = articleData.ClassName;
this.lblTitle.Text = articleData.Title;
this.lblContent.Text = articleData.Content;
this.lblDateTime.Text = articleData.DateTime.ToString().Substring(0,10);
this.lblHits.Text = articleData.Hits.ToString();
this.lblMemberName.Text = articleData.MemberName;
}
//linkButComment_Click
protected void linkButComment_Click(object sender, EventArgs e)
{
this.tabAddComment.Visible = true;
}
protected void butAddComment_Click(object sender, EventArgs e)
{
//添加评论
//获取新闻ID
//判断是否验证码输入正确
string imageCode = Session["imageCode"].ToString();
if (imageCode != txtCode.Text.ToString())
{
ClientScript.RegisterStartupScript(this.GetType(),"imageCode","<script>alert('验证码输入错误')</script>");
this.txtCode.Text = "";
return;
}
Comment comment = new Comment();
comment.Article = int.Parse(this.hidArticleID.Value.ToString());
comment.Name = txtName.Text.ToString();
comment.Content = txtComentContent.Text.ToString();
CommentSystem com = new CommentSystem();
bool flg = com.CommentAdd(comment);
if (flg)
{
ClientScript.RegisterStartupScript(this.GetType(), "comment", "<script>alert('添加成功!')</script>");
this.txtComentContent.Text = "";
this.tabAddComment.Visible = false;
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "comment", "<script>alert('添加失败!')</script>");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -