冯 海

一个程序新人菜鸟的日记,希望大家多多关照。QQ:32316131

bootstrap adminlte教程8:问答系统的ClubContents的回复页面

要回复,肯定需要一个sting ID,这个ID就是主题 的ID.

然后RlpyId,要等于这个ID。

1.控制器

// GET: ClubContents/CreateRLPY
		[HttpGet]
		public async Task<ActionResult> CreateRlpy(string Id)
		{
			if (Id == null)
			{
				return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
			}
			ClubContent clubContent = await db.ClubContents.FindAsync(Id);
			if (clubContent == null)
			{
				return HttpNotFound();
			}
			return View(clubContent);

		}


		/// <summary>
		/// 回复的方法
		/// </summary>
		/// <param name="clubContent"></param>
		/// <returns></returns>
		[HttpPost]
		[ValidateAntiForgeryToken]
		[ValidateInput(false)]
		public async Task<ActionResult> CreateRlpy([Bind(Include = "Id,CreatTime,EditTime,ColumnId,Title,Contents,CreatUser,ReplyID,PcIp,ReplyCount,ClubPermission,ClubState,ClubOerder")] ClubContent clubContent,string Id,int count)
		{
			var dt = DateTime.Now;
			string str = dt.ToString("yyyyMMddHHmmss");
			clubContent.Id = str;
			clubContent.ReplyID = Id;
			clubContent.CreatTime = DateTime.Now;
			clubContent.EditTime = DateTime.Now;
			clubContent.ReplyCount = count+1;
			clubContent.ClubOerder = 0;
			clubContent.PcIp = Request.UserHostAddress;
			clubContent.CreatUser = Session["username"].ToString();
			clubContent.ClubHeadPic = Session["headerPic"].ToString();


			if (ModelState.IsValid)
			{
				db.ClubContents.Add(clubContent);
				await db.SaveChangesAsync();
				return RedirectToAction("Index");
			}

			return View(clubContent);
		}

  

2.视图

@model jsdhh2.Models.ClubContent

@{
	ViewBag.Title = "Create";
}
<!-- Content Header (Page header) -->
<section class="content-header">
	<h1>
		我要回复
		<small>我正在用心的解答~</small>
	</h1>
	<ol class="breadcrumb">
		<li><a href="#"><i class="fa fa-dashboard"></i> Level</a></li>
		<li class="active">Here</li>
	</ol>
</section>
<!--end Content Header (Page header) -->
<section class="content">
	<div class="btn-group" role="group" aria-label="...">
		<a class="btn btn-success" href="~/ClubContents" role="button">返回列表</a>
	</div>
	<hr />
	<div class="detail-about ">
		<div class="col-md-1  col-xs-3">
			<img src=@Html.DisplayFor(model => model.ClubHeadPic) class="img-circle" style="width: 46px; height: 46px;">
		</div>
		 
			 @Html.DisplayFor(model => model.CreatUser) 
			<br style="padding-left:90px; margin-top:-20px;">  @Html.DisplayFor(model => model.CreatTime)  
		 
				
		 
	</div>
 <h4> @Html.DisplayFor(model => model.Title) </h4> 

	<div class="detail-about ">我要回复</div>
	<h5></h5>

@using (Html.BeginForm("CreateRlpy", "ClubContents", new { Id = Model.Id, count = Model.ReplyCount }, FormMethod.Post))
{
	@Html.AntiForgeryToken()

	@Html.ValidationSummary(true, "", new { @class = "text-danger" })

	<script id="neirong" name="Contents" type="text/plain">
		回复内容
	</script>
	<h4></h4>

	<div style="display:none;">


		@Html.EditorFor(model => model.ClubPermission, new { htmlAttributes = new { @class = "form-control" } })
 

	</div>

	<div class="form-group left">

		<div class="col-md-12 left">
			<div class="col-md-2 col-xs-6">
			 
				@Html.DropDownListFor(m => m.ClubState, new List<SelectListItem>()
	   {
		   new SelectListItem() { Text= "完结", Value = "1"},
		   new SelectListItem() { Text= "不完结", Value = "0" },

	   })
			</div>
			<input type="submit" value="回复" class="btn btn-primary" />
		</div>
	</div>

}

	


</section>
@section Scripts {

	<script type="text/javascript">

	var editor = UE.getEditor('neirong', {
			//这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
		toolbars: [['FullScreen', 'Undo', 'Unlink', 'Redo', 'Link', 'Simpleupload', 'Emotion', 'Unlink', 'Attachment', 'Bold', 'underline', 'forecolor', 'backcolor', 'fontsize', 'justifyleft', 'justifycenter']],
			//focus时自动清空初始化时的内容
			autoClearinitialContent: true,
			//关闭字数统计
			wordCount: false,
			//关闭elementPath
			elementPathEnabled: false,
			//默认的编辑区域高度
			initialFrameHeight: 150,
			//更多其他参数,请参考ueditor.config.js中的配置项
		maximumWords:500
		});
	</script>



}

  

3,效果图

posted @ 2017-06-03 18:10  秋天来了哟  阅读(381)  评论(0编辑  收藏  举报
认识就是缘份,愿天下人都快乐!
QQ: 32316131
Email: 32316131@qq.com