using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Microsoft.Security.Application;
using OutOfThisWorld.Domain.Entities;
using OutOfThisWorld.Domain.Concrete;
using OutOfThisWorld.WebUI.Models;
namespace OutOfThisWorld.WebUI.Controllers
{
public class BlogPostController : Controller
{
public int PageSize = 3;
private EFDbContext db = new EFDbContext();
//
// GET: /BlogPost/
public ActionResult Index(string category, int page = 1)
{
PostsListViewModel viewModel = new PostsListViewModel
{
Posts = db.Posts.Include(p => p.Client).Include(p => p.User).Include(p => p.Category).Include(p => p.Blog).Include(p => p.Example)
.Where(p => category == null || p.Category.CategoryName == category)
.OrderBy(p => p.PostID)
.Skip((page - 1) * PageSize)
.Take(PageSize),
PagingInfo = new PagingInfo
{
CurrentPage = page,
ItemsPerPage = PageSize,
TotalItems = category == null?
db.Posts.Count() :
db.Posts.Where(e => e.Category.CategoryName == category).Count()
},CurrentCategory = category
};
return View(viewModel);
}
public PartialViewResult PostComment(int id = 0)
{
Post post = db.Posts.Find(id);
ViewBag.PostID = id;
return PartialView();
}
[HttpPost]
public JsonResult PostComment(Comment comment)
{
try
{
var postc = comment;
db.Comments.Add(postc);
db.SaveChanges();
return Json(new {ok = true, data = postc, message = "Comment Saved"});
}
catch (Exception ex)
{
return Json(new {ok = false, message = ex.Message});
}
}
[Authorize(Roles = "Admins")]
public ActionResult List()
{
var posts = db.Posts.Include(p => p.Client).Include(p => p.User).Include(p => p.Category).Include(p => p.Blog).Include(p => p.Example);
return View(posts.ToList());
}
public PartialViewResult BlogWidget()
{
var posts = db.Posts.Include(p => p.Client).Include(p => p.User).Include(p => p.Category).Include(p => p.Blog).Include(p => p.Example);
return PartialView(posts.ToList());
}
//
// GET: /BlogPost/Details/5
public ActionResult Details(int id = 0)
{
Post post = db.Posts.Find(id);
if (post == null)
{
return HttpNotFound();
}
return View(post);
}
//
// GET: /BlogPost/Create
[Authorize(Roles = "Admins")]
public ActionResult Create()
{
ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "Name");
ViewBag.UserID = new SelectList(db.Users, "UserID", "UserName");
ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName");
ViewBag.BlogID = new SelectList(db.Blogs, "BlogID", "Title");
ViewBag.ExampleID = new SelectList(db.Examples, "ExampleID", "Name");
return View();
}
//
// POST: /BlogPost/Create
[HttpPost]
[ValidateAntiForgeryToken]
[Authorize(Roles = "Admins")]
public ActionResult Create(Post post)
{
if (ModelState.IsValid)
{
post.Body = Sanitizer.GetSafeHtmlFragment(post.Body);
db.Posts.Add(post);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "Name", post.ClientID);
ViewBag.UserID = new SelectList(db.Users, "UserID", "UserName", post.UserID);
ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", post.CategoryID);
ViewBag.BlogID = new SelectList(db.Blogs, "BlogID", "Title", post.BlogID);
ViewBag.ExampleID = new SelectList(db.Examples, "ExampleID", "Name", post.ExampleID);
return View(post);
}
//
// GET: /BlogPost/Edit/5
[Authorize(Roles = "Admins")]
public ActionResult Edit(int id = 0)
{
Post post = db.Posts.Find(id);
if (post == null)
{
return HttpNotFound();
}
ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "Name", post.ClientID);
ViewBag.UserID = new SelectList(db.Users, "UserID", "UserName", post.UserID);
ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", post.CategoryID);
ViewBag.BlogID = new SelectList(db.Blogs, "BlogID", "Title", post.BlogID);
ViewBag.ExampleID = new SelectList(db.Examples, "ExampleID", "Name", post.ExampleID);
return View(post);
}
//
// POST: /BlogPost/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
[Authorize(Roles = "Admins")]
public ActionResult Edit(Post post)
{
if (ModelState.IsValid)
{
post.Body = Sanitizer.GetSafeHtmlFragment(post.Body);
db.Entry(post).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "Name", post.ClientID);
ViewBag.UserID = new SelectList(db.Users, "UserID", "UserName", post.UserID);
ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", post.CategoryID);
ViewBag.BlogID = new SelectList(db.Blogs, "BlogID", "Title", post.BlogID);
ViewBag.ExampleID = new SelectList(db.Examples, "ExampleID", "Name", post.ExampleID);
return View(post);
}
//
// GET: /BlogPost/Delete/5
[Authorize(Roles = "Admins")]
public ActionResult Delete(int id = 0)
{
Post post = db.Posts.Find(id);
if (post == null)
{
return HttpNotFound();
}
return View(post);
}
//
// POST: /BlogPost/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
[Authorize(Roles = "Admins")]
public ActionResult DeleteConfirmed(int id)
{
Post post = db.Posts.Find(id);
db.Posts.Remove(post);
db.SaveChanges();
return RedirectToAction("Index");
}
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
}
}
ThThis is my Comment Controller it's really there for admin purposes but I would be willing to make the partial view from here if I could get it to work
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using OutOfThisWorld.Domain.Entities;
using OutOfThisWorld.Domain.Concrete;
namespace OutOfThisWorld.WebUI.Controllers
{
public class CommentController : Controller
{
private EFDbContext db = new EFDbContext();
//
// GET: /Comment/
public ActionResult Index()
{
var comments = db.Comments.Include(c => c.Post).Include(c => c.User);
return View(comments.ToList());
}
//
// GET: /Comment/Details/5
public ActionResult Details(int id = 0)
{
Comment comment = db.Comments.Find(id);
if (comment == null)
{
return HttpNotFound();
}
return View(comment);
}
//
// GET: /Comment/Create
public ActionResult Create()
{
ViewBag.PostID = new SelectList(db.Posts, "PostID", "Title");
ViewBag.UserID = new SelectList(db.Users, "UserID", "UserImageUrl");
return View();
}
//
// POST: /Comment/Create
[HttpPost]
public ActionResult Create(Comment comment)
{
if (ModelState.IsValid)
{
db.Comments.Add(comment);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.PostID = new SelectList(db.Posts, "PostID", "Title", comment.PostID);
ViewBag.UserID = new SelectList(db.Users, "UserID", "UserImageUrl", comment.UserID);
return View(comment);
}
//
// GET: /Comment/Edit/5
public ActionResult Edit(int id = 0)
{
Comment comment = db.Comments.Find(id);
if (comment == null)
{
return HttpNotFound();
}
ViewBag.PostID = new SelectList(db.Posts, "PostID", "Title", comment.PostID);
ViewBag.UserID = new SelectList(db.Users, "UserID", "UserImageUrl", comment.UserID);
return View(comment);
}
//
// POST: /Comment/Edit/5
[HttpPost]
public ActionResult Edit(Comment comment)
{
if (ModelState.IsValid)
{
db.Entry(comment).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.PostID = new SelectList(db.Posts, "PostID", "Title", comment.PostID);
ViewBag.UserID = new SelectList(db.Users, "UserID", "UserImageUrl", comment.UserID);
return View(comment);
}
//
// GET: /Comment/Delete/5
public ActionResult Delete(int id = 0)
{
Comment comment = db.Comments.Find(id);
if (comment == null)
{
return HttpNotFound();
}
return View(comment);
}
//
// POST: /Comment/Delete/5
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id)
{
Comment comment = db.Comments.Find(id);
db.Comments.Remove(comment);
db.SaveChanges();
return RedirectToAction("Index");
}
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
}
}
This my Details view the host for the partial view "PostComment"
@model OutOfThisWorld.Domain.Entities.Post
@{
ViewBag.Title = "Details";
ViewBag.id = Model.PostID;
}
@section featured{
@{Html.RenderAction("Bottom", "Portfolio" );}
}
<div class="blog-post">
<!-- Begin Posts -->
<div class="content">
<!-- Begin Post -->
<div class="post">
<!-- Begin Post Info -->
<div class="post-info">
<!-- Begin Date -->
<div class="post-date"> <span class="day">@Model.DateCreated.Day</span> <span class="month"> @Model.DateCreated.ToString("MMM") </span> <span class="year">@Model.DateCreated.Year</span> </div>
<!-- End Date -->
<!-- Begin Title -->
<div class="post-title">
<h1>@Model.Title </h1>
<div class="post-meta"> <span class="comments"><a href="#">0 Comments</a></span> <span class="categories"><a href="#">@Model.Category.CategoryName</a></span></div>
</div>
<!-- End Title -->
</div>
<!-- End Post Info -->
<div class="post-text"> <img src="@Model.Example.LargeImageUrl" width="595" height="300" alt="@Model.Example.Description" /> <br />
<p>@Model.Body</p>
<br />
<br />
<!--Refactor with infoes-->
<blockquote>Our mission is strive to grow past the bounds of gravity and reality and achieve something OUT OF THIS WORLD.</blockquote>
<br />
<br />
<br />
<ul class="regulartext">
<li><span>Web Design - </span>Html, CSS, and Javascript and as well as Dynamic sites using ASP.net MVC.</li>
<li><span>Photography - </span>Weddings, Portraits, Real Estate photos, Automobile photos you name it.</li>
<li><span>Graphic Design - </span>Logos, CD covers, Flyers, Business cards, Stationery again you name it.</li>
<li><span>Marketing - </span>Bulk Email, Bulk text messages, web banners and strip and repeat banners.</li>
</ul>
<br />
<br />
</div>
<!-- End Text -->
<span class="tags"><a href="#">Black & White</a>, <a href="#">Color</a>, <a href="#">Portfolio</a></span> </div>
<!-- End Post -->
<div class="hr2"></div>
<!-- Begin Comments -->
<h3>Responses to "@Model.Title"</h3>
<!-- Begin Comments -->
<div id="comments">
<ol id="singlecomments" class="commentlist">
@if (Model.Comments != null)
{
foreach (var c in Model.Comments)
{
<li class= "clearfix">
<div class="user"><img alt="" src="~/Images/art/a4.jpg" height="60" width="60" class="avatar" /></div>
<div class="message">
<div class="info">
<h3><a href="#">@c.User.UserName</a></h3>
<span class="date">@c.DateCreated</span> <a class="reply-link" href="#">Reply</a> </div>
<p>@c.CommentBody</p>
</div>
<div class="clear"></div>
</li>
}
}
else
{<li>No Comments</li>}
</ol>
</div>
<!-- End Comments -->
<!-- Begin Form -->
@{Html.RenderAction("PostComment","BlogPost"); }
<!-- End Form -->
<!-- End Comments -->
</div>
<!-- End Posts -->
<!-- Begin Sidebar -->
<div class="sidebar">
<div class="sidebar-box">
@{Html.RenderAction("BlogWidget", "BlogPost");}
</div>
<div class="sidebar-box">
<h4>Web Design</h4>
<p>The web is constantly changing and growing and we changing with you want a Web Designer on the cutting edge then you found the right place.</p>
<br/>
<h4>Photography</h4>
<p>Photography is more than just a hobby to us. We guarantee to deliver a quality product everyday every time that will exceed you expectations.</p>
<br/>
<h4>Graphic Design</h4>
<p>Businesses need Logos, Flyers, Business Cards etc. You can get all that through us. Why go somewhere else when you can get best quality here at a fair price.</p>
<br/>
<h4>Marketing</h4>
<p>We start with great photography, add Superior Graphic Design, bake it with years of know-how ,and then distribute it to the masses inspiring desire in the products the portray.</p>
</div>
<div class="sidebar-box">
<h4>Search</h4>
<form class="searchform" method="get">
<input type="text" id="s" name="s" value="type and hit enter" onfocus="this.value=''" onblur="this.value='type and hit enter'"/>
</form>
</div>
<div class="sidebar-box">
@{Html.RenderAction("CategoryList", "Portfolio");}
</div>
<div class="sidebar-box">
<!--Make tags search -->
<h4>Tags</h4>
<div class="tag-list">
<ul>
<li><a href="#">journal</a></li>
<li><a href="#">photography</a></li>
<li><a href="#">design</a></li>
<li><a href="#">inspiration</a></li>
<li><a href="#">fun</a></li>
<li><a href="#">casual</a></li>
<li><a href="#">business</a></li>
<li><a href="#">web</a></li>
<li><a href="#">color</a></li>
<li><a href="#">portfolio</a></li>
</ul>
</div>
</div>
<div class="sidebar-box">
<!--Add links to other websites -->
<!--<h4>Sponsors</h4>
<ul class="ads">
<li><a href="#"><img src="images/art/ad1.jpg" alt="" /></a></li>
<li><a href="#"><img src="images/art/ad2.jpg" alt="" /></a></li>
<li><a href="#"><img src="images/art/ad3.jpg" alt="" /></a></li>
<li><a href="#"><img src="images/art/ad4.jpg" alt="" /></a></li>
</ul>-->
</div>
</div>
<!-- End Sidebar -->
</div>
And here is the Problem Partial view that I can't seem to pass the PostID to it called PostComment if you are looking for it is in the BlogPost controller
MEGADEE79
Member
2 Points
5 Posts
Re: Adding Comments to Post
May 20, 2012 06:10 PM|LINK
This is my Post controller
using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Web; using System.Web.Mvc; using Microsoft.Security.Application; using OutOfThisWorld.Domain.Entities; using OutOfThisWorld.Domain.Concrete; using OutOfThisWorld.WebUI.Models; namespace OutOfThisWorld.WebUI.Controllers { public class BlogPostController : Controller { public int PageSize = 3; private EFDbContext db = new EFDbContext(); // // GET: /BlogPost/ public ActionResult Index(string category, int page = 1) { PostsListViewModel viewModel = new PostsListViewModel { Posts = db.Posts.Include(p => p.Client).Include(p => p.User).Include(p => p.Category).Include(p => p.Blog).Include(p => p.Example) .Where(p => category == null || p.Category.CategoryName == category) .OrderBy(p => p.PostID) .Skip((page - 1) * PageSize) .Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = category == null? db.Posts.Count() : db.Posts.Where(e => e.Category.CategoryName == category).Count() },CurrentCategory = category }; return View(viewModel); } public PartialViewResult PostComment(int id = 0) { Post post = db.Posts.Find(id); ViewBag.PostID = id; return PartialView(); } [HttpPost] public JsonResult PostComment(Comment comment) { try { var postc = comment; db.Comments.Add(postc); db.SaveChanges(); return Json(new {ok = true, data = postc, message = "Comment Saved"}); } catch (Exception ex) { return Json(new {ok = false, message = ex.Message}); } } [Authorize(Roles = "Admins")] public ActionResult List() { var posts = db.Posts.Include(p => p.Client).Include(p => p.User).Include(p => p.Category).Include(p => p.Blog).Include(p => p.Example); return View(posts.ToList()); } public PartialViewResult BlogWidget() { var posts = db.Posts.Include(p => p.Client).Include(p => p.User).Include(p => p.Category).Include(p => p.Blog).Include(p => p.Example); return PartialView(posts.ToList()); } // // GET: /BlogPost/Details/5 public ActionResult Details(int id = 0) { Post post = db.Posts.Find(id); if (post == null) { return HttpNotFound(); } return View(post); } // // GET: /BlogPost/Create [Authorize(Roles = "Admins")] public ActionResult Create() { ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "Name"); ViewBag.UserID = new SelectList(db.Users, "UserID", "UserName"); ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName"); ViewBag.BlogID = new SelectList(db.Blogs, "BlogID", "Title"); ViewBag.ExampleID = new SelectList(db.Examples, "ExampleID", "Name"); return View(); } // // POST: /BlogPost/Create [HttpPost] [ValidateAntiForgeryToken] [Authorize(Roles = "Admins")] public ActionResult Create(Post post) { if (ModelState.IsValid) { post.Body = Sanitizer.GetSafeHtmlFragment(post.Body); db.Posts.Add(post); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "Name", post.ClientID); ViewBag.UserID = new SelectList(db.Users, "UserID", "UserName", post.UserID); ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", post.CategoryID); ViewBag.BlogID = new SelectList(db.Blogs, "BlogID", "Title", post.BlogID); ViewBag.ExampleID = new SelectList(db.Examples, "ExampleID", "Name", post.ExampleID); return View(post); } // // GET: /BlogPost/Edit/5 [Authorize(Roles = "Admins")] public ActionResult Edit(int id = 0) { Post post = db.Posts.Find(id); if (post == null) { return HttpNotFound(); } ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "Name", post.ClientID); ViewBag.UserID = new SelectList(db.Users, "UserID", "UserName", post.UserID); ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", post.CategoryID); ViewBag.BlogID = new SelectList(db.Blogs, "BlogID", "Title", post.BlogID); ViewBag.ExampleID = new SelectList(db.Examples, "ExampleID", "Name", post.ExampleID); return View(post); } // // POST: /BlogPost/Edit/5 [HttpPost] [ValidateAntiForgeryToken] [Authorize(Roles = "Admins")] public ActionResult Edit(Post post) { if (ModelState.IsValid) { post.Body = Sanitizer.GetSafeHtmlFragment(post.Body); db.Entry(post).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "Name", post.ClientID); ViewBag.UserID = new SelectList(db.Users, "UserID", "UserName", post.UserID); ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", post.CategoryID); ViewBag.BlogID = new SelectList(db.Blogs, "BlogID", "Title", post.BlogID); ViewBag.ExampleID = new SelectList(db.Examples, "ExampleID", "Name", post.ExampleID); return View(post); } // // GET: /BlogPost/Delete/5 [Authorize(Roles = "Admins")] public ActionResult Delete(int id = 0) { Post post = db.Posts.Find(id); if (post == null) { return HttpNotFound(); } return View(post); } // // POST: /BlogPost/Delete/5 [HttpPost, ActionName("Delete")] [ValidateAntiForgeryToken] [Authorize(Roles = "Admins")] public ActionResult DeleteConfirmed(int id) { Post post = db.Posts.Find(id); db.Posts.Remove(post); db.SaveChanges(); return RedirectToAction("Index"); } protected override void Dispose(bool disposing) { db.Dispose(); base.Dispose(disposing); } } }ThThis is my Comment Controller it's really there for admin purposes but I would be willing to make the partial view from here if I could get it to work
using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Web; using System.Web.Mvc; using OutOfThisWorld.Domain.Entities; using OutOfThisWorld.Domain.Concrete; namespace OutOfThisWorld.WebUI.Controllers { public class CommentController : Controller { private EFDbContext db = new EFDbContext(); // // GET: /Comment/ public ActionResult Index() { var comments = db.Comments.Include(c => c.Post).Include(c => c.User); return View(comments.ToList()); } // // GET: /Comment/Details/5 public ActionResult Details(int id = 0) { Comment comment = db.Comments.Find(id); if (comment == null) { return HttpNotFound(); } return View(comment); } // // GET: /Comment/Create public ActionResult Create() { ViewBag.PostID = new SelectList(db.Posts, "PostID", "Title"); ViewBag.UserID = new SelectList(db.Users, "UserID", "UserImageUrl"); return View(); } // // POST: /Comment/Create [HttpPost] public ActionResult Create(Comment comment) { if (ModelState.IsValid) { db.Comments.Add(comment); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.PostID = new SelectList(db.Posts, "PostID", "Title", comment.PostID); ViewBag.UserID = new SelectList(db.Users, "UserID", "UserImageUrl", comment.UserID); return View(comment); } // // GET: /Comment/Edit/5 public ActionResult Edit(int id = 0) { Comment comment = db.Comments.Find(id); if (comment == null) { return HttpNotFound(); } ViewBag.PostID = new SelectList(db.Posts, "PostID", "Title", comment.PostID); ViewBag.UserID = new SelectList(db.Users, "UserID", "UserImageUrl", comment.UserID); return View(comment); } // // POST: /Comment/Edit/5 [HttpPost] public ActionResult Edit(Comment comment) { if (ModelState.IsValid) { db.Entry(comment).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.PostID = new SelectList(db.Posts, "PostID", "Title", comment.PostID); ViewBag.UserID = new SelectList(db.Users, "UserID", "UserImageUrl", comment.UserID); return View(comment); } // // GET: /Comment/Delete/5 public ActionResult Delete(int id = 0) { Comment comment = db.Comments.Find(id); if (comment == null) { return HttpNotFound(); } return View(comment); } // // POST: /Comment/Delete/5 [HttpPost, ActionName("Delete")] public ActionResult DeleteConfirmed(int id) { Comment comment = db.Comments.Find(id); db.Comments.Remove(comment); db.SaveChanges(); return RedirectToAction("Index"); } protected override void Dispose(bool disposing) { db.Dispose(); base.Dispose(disposing); } } }This my Details view the host for the partial view "PostComment"
@model OutOfThisWorld.Domain.Entities.Post @{ ViewBag.Title = "Details"; ViewBag.id = Model.PostID; } @section featured{ @{Html.RenderAction("Bottom", "Portfolio" );} } <div class="blog-post"> <!-- Begin Posts --> <div class="content"> <!-- Begin Post --> <div class="post"> <!-- Begin Post Info --> <div class="post-info"> <!-- Begin Date --> <div class="post-date"> <span class="day">@Model.DateCreated.Day</span> <span class="month"> @Model.DateCreated.ToString("MMM") </span> <span class="year">@Model.DateCreated.Year</span> </div> <!-- End Date --> <!-- Begin Title --> <div class="post-title"> <h1>@Model.Title </h1> <div class="post-meta"> <span class="comments"><a href="#">0 Comments</a></span> <span class="categories"><a href="#">@Model.Category.CategoryName</a></span></div> </div> <!-- End Title --> </div> <!-- End Post Info --> <div class="post-text"> <img src="@Model.Example.LargeImageUrl" width="595" height="300" alt="@Model.Example.Description" /> <br /> <p>@Model.Body</p> <br /> <br /> <!--Refactor with infoes--> <blockquote>Our mission is strive to grow past the bounds of gravity and reality and achieve something OUT OF THIS WORLD.</blockquote> <br /> <br /> <br /> <ul class="regulartext"> <li><span>Web Design - </span>Html, CSS, and Javascript and as well as Dynamic sites using ASP.net MVC.</li> <li><span>Photography - </span>Weddings, Portraits, Real Estate photos, Automobile photos you name it.</li> <li><span>Graphic Design - </span>Logos, CD covers, Flyers, Business cards, Stationery again you name it.</li> <li><span>Marketing - </span>Bulk Email, Bulk text messages, web banners and strip and repeat banners.</li> </ul> <br /> <br /> </div> <!-- End Text --> <span class="tags"><a href="#">Black & White</a>, <a href="#">Color</a>, <a href="#">Portfolio</a></span> </div> <!-- End Post --> <div class="hr2"></div> <!-- Begin Comments --> <h3>Responses to "@Model.Title"</h3> <!-- Begin Comments --> <div id="comments"> <ol id="singlecomments" class="commentlist"> @if (Model.Comments != null) { foreach (var c in Model.Comments) { <li class= "clearfix"> <div class="user"><img alt="" src="~/Images/art/a4.jpg" height="60" width="60" class="avatar" /></div> <div class="message"> <div class="info"> <h3><a href="#">@c.User.UserName</a></h3> <span class="date">@c.DateCreated</span> <a class="reply-link" href="#">Reply</a> </div> <p>@c.CommentBody</p> </div> <div class="clear"></div> </li> } } else {<li>No Comments</li>} </ol> </div> <!-- End Comments --> <!-- Begin Form --> @{Html.RenderAction("PostComment","BlogPost"); } <!-- End Form --> <!-- End Comments --> </div> <!-- End Posts --> <!-- Begin Sidebar --> <div class="sidebar"> <div class="sidebar-box"> @{Html.RenderAction("BlogWidget", "BlogPost");} </div> <div class="sidebar-box"> <h4>Web Design</h4> <p>The web is constantly changing and growing and we changing with you want a Web Designer on the cutting edge then you found the right place.</p> <br/> <h4>Photography</h4> <p>Photography is more than just a hobby to us. We guarantee to deliver a quality product everyday every time that will exceed you expectations.</p> <br/> <h4>Graphic Design</h4> <p>Businesses need Logos, Flyers, Business Cards etc. You can get all that through us. Why go somewhere else when you can get best quality here at a fair price.</p> <br/> <h4>Marketing</h4> <p>We start with great photography, add Superior Graphic Design, bake it with years of know-how ,and then distribute it to the masses inspiring desire in the products the portray.</p> </div> <div class="sidebar-box"> <h4>Search</h4> <form class="searchform" method="get"> <input type="text" id="s" name="s" value="type and hit enter" onfocus="this.value=''" onblur="this.value='type and hit enter'"/> </form> </div> <div class="sidebar-box"> @{Html.RenderAction("CategoryList", "Portfolio");} </div> <div class="sidebar-box"> <!--Make tags search --> <h4>Tags</h4> <div class="tag-list"> <ul> <li><a href="#">journal</a></li> <li><a href="#">photography</a></li> <li><a href="#">design</a></li> <li><a href="#">inspiration</a></li> <li><a href="#">fun</a></li> <li><a href="#">casual</a></li> <li><a href="#">business</a></li> <li><a href="#">web</a></li> <li><a href="#">color</a></li> <li><a href="#">portfolio</a></li> </ul> </div> </div> <div class="sidebar-box"> <!--Add links to other websites --> <!--<h4>Sponsors</h4> <ul class="ads"> <li><a href="#"><img src="images/art/ad1.jpg" alt="" /></a></li> <li><a href="#"><img src="images/art/ad2.jpg" alt="" /></a></li> <li><a href="#"><img src="images/art/ad3.jpg" alt="" /></a></li> <li><a href="#"><img src="images/art/ad4.jpg" alt="" /></a></li> </ul>--> </div> </div> <!-- End Sidebar --> </div>And here is the Problem Partial view that I can't seem to pass the PostID to it called PostComment if you are looking for it is in the BlogPost controller
@model OutOfThisWorld.Domain.Entities.Comment
<div class="comment-form">
<h3>Leave a Reply</h3>
<div class="form-container">
@using (Html.BeginForm("PostComment", "BlogPost", FormMethod.Post, new { enctype = "multipart/form", @class = "forms chorm" }))
{
@Html.ValidationSummary(true)
{
var refr = Model.PostID = 0;
ViewBag.id = refr;
}
<fieldset>
<legend>Comment</legend>
<div class="pform">
<div class="editor-label"><label>Name</label></div>
<div class="editor-field">
@Html.EditorFor(model => model.User.UserName)
</div>
</div>
<div class="pform">
<div class="editor-label"><label>Email</label></div>
<div class="editor-field">
@Html.EditorFor(model => model.User.Email)
</div>
</div>
<div class="pform">
<div class="editor-label"><label>Date Created</label></div>
<div class="editor-field">
@Html.EditorFor(model => model.DateCreated)
</div>
</div>
<div class="pform">
<div class="editor-label"><label>Message</label></div>
<div class="editor-field">
@Html.TextAreaFor(model => model.CommentBody)
</div>
<div class="editor-field">
@Html.HiddenFor(model => model.PostID)
</div>
</div>
<div class="pform">
<p>
<input type="submit" value="Submit" name="submit" class="btn-submit" />
</p>
</div>
<input type="hidden" name="v_error" id="v-error" value="Required" />
<input type="hidden" name="v_email" id="v-email" value="Enter a valid email" />
</fieldset>
}
<div class="response"></div>
</div>
</div>