1

I am working on asp.net mvc3 application. In my application, User can post their comment and at that time i want to display their post in same page using ajax and jquery. This application is like facebook - we can share post, user can comment to post and all.

I have created two actions - setcomment -getcomment

how can i do, - at page load i want to display textarea and post button to post commnent and - below that all post of the user will be displayed on that - and user can post subcomments also.

I have my code working but in that i am using actionlink to go to another page and use refresh button to load page again.


i have

setcomment - 
            @model <NAMESPACE>.<MODELNAME>
            <some code>
 getcomment - 
            @model IEnumerable<<NAMESPACE>.<MODELNAME>>
            <some code>

i am not able to call

<div id="showusercomments" style="float: left; width: 75%">
    @Html.Partial("_GetUserComment")
 </div>

what can i do to solve this problem?

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
Bhargav
  • 451
  • 3
  • 13
  • 26

2 Answers2

0

Try using @Html.Action() instead of Html.Partial .

Also see:

Community
  • 1
  • 1
Ofer Zelig
  • 17,068
  • 9
  • 59
  • 93
0

You've got two options:

<div id="showusercomments" style="float: left; width: 75%">
    @Html.Action("_GetUserComment")
</div>

or, get the IEnumerable<...> in the parent page's controller and pass it to the partial:

<div id="showusercomments" style="float: left; width: 75%">
    @Html.Partial("_GetUserComment", Model.Comments)
</div>
Adam Flanagan
  • 3,052
  • 23
  • 31