views:

384

answers:

2

Assume I have on a page an article with the possibility to comment it. I have a submit form that submits via ajax and the OnComplete javascript method intercepts the result of the form submit. Each comment is smth like:

<div class="text">
<p class="details">
User <a href="http://www.mywebsitehere.com/user/3583/" rel="nofollow" class="f">Always_Dreaming</a> at 01/01/2009 - 11:13:52        </p>
<p>Here goes my text   :D</p>
</div>

I made an .ascx file from it, and I do tml.RenderPartial foreach comment. Now the question is how can I use this .ascx control to output the inserted content to the OnComplete method from client side.

PS. I want to use this approach and not to serialize the Comment object and to return the serialized data, take it wioth my js code and generate on the fly the html with data from the deserialized Comment object.

+1  A: 

What you need to do is use the PartialViewResult from the action that's invoked by your javascript call. The client side code can append it to the html using something like the jQuery append or html method calls.

Nigel Sampson
A: 

for those who are interested, I found a sample :) here

diadiora