English 中文(简体)
• 创造力,在视野中发挥作用?
原标题:Getting Create to work in a ViewModel?

因此,我有一个半工作博客,我正试图获得充分运作的评论。 现在,我有所有职位,与他们的所有相应评论都是正确的。 其中一个问题是,你实际上无法通过网站增加评论(我刚刚以人工方式这样做)。

我以前在我的主计长中做了“准确”的方法,但只能通过自动手法。

现在,我把“观点”带到下面的网页上(这些话题以及与博客本身有关的评论)。

public ActionResult Post(int id)
{
    var post = (from p in db.Set<BlogPost>()
                where p.id == id
                select new PostViewModel
                           {
                              Id = p.id,
                              Title = p.Title,
                              DateCreated = p.DateCreated,
                              Content = p.Content,
                              Topics = p.Topics,
                              Comments = p.Comments,
                              CommentCount = p.Comments.Count
                          }).Single();

    return View(post);
}

然后,我担任我的职务。

<div class="blogpost">
    <h2>@Model.Title</h2>
    <div class="post_info">@Model.DateCreated<span class="right">Blog</span></div>
    <p>@Html.Raw(Model.Content)</p>
    <div class="post_close">
        <span class="left">
            @foreach (var topic in Model.Topics)
            {
                <text>@Html.DisplayFor(modelItem => topic.Name) </text>
            }
        </span>
        <span class="right">
            <img src="../../Content/images/comment.jpg" alt="" />
            @if (Model.CommentCount > 1 || Model.CommentCount == 0)
            { 
                @Model.CommentCount <text>comments</text> }
            else
            {
                @Model.CommentCount <text>comment</text>
            }
        </span>
    </div>
</div>
<div id="comments">
    @foreach (var comment in Model.Comments)
    {
        <b>@Html.DisplayFor(modelItem => comment.Name)</b> <text>says... </text><br />
        <i>@Html.DisplayFor(modelItem => comment.Content)</i><br />
    }
</div>

在“意见”四中,我要为人们创造新的意见增添一个途径。 显然,这样做并不单单单是评注模式,而是采用传统方式。 任何关于从何处开始的建议?

我对MVC3来说基本上是新的,与我使用的网络表格相比,张贴背书的整个想法非常混淆。 任何帮助都是有益的,感谢你!

(我将把这个职位与可能需要的其他信息化的人联系起来)

最佳回答

我已经说过了,我非常建议你开始学习一些que。 我本人将创建一种麻风味评论箱,提交纽顿,只有经认证的用户、开张者或海关会员提供人才能使用。

你们想学习如何使用jax和$,以及用这些方法使用json物体。

<input type="textarea" id="commentBox"></input>
<input type="button" onclick="submitComment();" value="SUBMIT" />

function submitComment(){
     var newComment = {
         comment: $("#commentBox").val(),
         blogpostid: $("#PostID").val()
     }

     $.post("/BlogPost/AddComment",newComment,function(data){
           // append text to bottom of comments
           if(data.Error){
               alert(data.ErrorMessage);
           } else {
               $("#comments").append( <div id="commentDiv">  + newComment.comment +  </div >);
           }
     });
}

页: 1 员额控制员

public JsonResult AddComment(string comment, int blogpostid)
{
      // snag user info from authenticated session

      // save comment

      // return an object that has a boolean and a string it would look something like this.

      var commentResult = new object{ Error = true, ErrorMessage =  we could not save the comment };

      return Json(commentResult);
}

这只字不提所有事项,在客户和服务器方面,包括安全措施,还需要做更多的工作。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签