Click here to Skip to main content
15,891,851 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm having a detail view in which there will be a conversation, and even comment box in conversation. I had a comment box in partial view. but had an issue when decided to refresh just the conversation on creating comment.
I know i can bind below code in partial view. but i have difficulty in calling action method for it.
So it will have details view code and then below code

<div class="row">
        <div class="panel-group" id="accordion">
            @foreach (var convo in Model.TicketConversation.OrderByDescending(x => x.LastUpdatedTimestamp))
            {
                <div class="col-md-10 col-md-offset-1" style="padding-removed 5px;">
                    <div class="panel panel-default">
                        <div class="panel-heading removePaddingBottom" data-toggle="collapse" data-target="#accord-convo-@convo.id" style="background-color: inherit;" id="accordHeading-@convo.id">
                            <a style="text-decoration: none !important; color: inherit; width: 100px;">
                                <span style="font-size: 16px; font-weight: bold; vertical-align: middle !important;">class="fa fa-chevron-right" id="accord-heading-icon-@convo.id"__^
                                            </div>
                                            <div class="col-md-offset-1 col-md-10 removePadding" style="margin-removed 10px;">
                                                @lastmessage.Message
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-offset-6 col-md-5 text-right text-muted" style="margin-removed 10px;">
                                                <small>
                                                    ^__em__^Posted by @lastmessage.CommenterName @@ @lastmessage.MessageTimestamp
                                                </small>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="accord-convo-@convo.id" class="panel-collapse collapse">
                            <div class="panel-body" style="padding: 0;">
                                @if (convo.IsReadOnly == false @*&& Model.IsClosed == false*@)
                                {
                                    <div class="row">
                                        @*<div class="col-md-12" style="padding-removed 3px; padding-removed 3px;">
                                            <a href="@Url.Action(" replyquery=", new { cid = convo.id })" class="pull-right btn btn-sm btn-default">^__i class="fa fa-reply"> Reply</a>
                                        </div>*@
                                      
                                        ---- here i'm calling partial view for comment box---
                                }
                                @foreach (var item in convo.ConversationComments)
                                {
                                    <div>
                                        <div class="message-border @item.DisplayCssClass">
                                            <div class="row">
                                                <div class="col-md-offset-1 col-md-10 removePadding" style="margin-removed 5px;">
                                                    ^__strong>@item.TypeOfContact
                                                </div>
                                                <div class="col-md-offset-1 col-md-10 removePadding" style="margin-removed 10px;">
                                                    @item.Message
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-md-5 text-right text-muted">
                                                    <small>
                                                        ^__em>Posted by @item.CommenterName @@ @item.MessageTimestamp
                                                    </small>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                }
                            </div>
                        </div>
                    </div>
                </div>
            }
        </div>
    </div>


which method can be called to get conversation list?? do i need to write a new action method.
Posted
Updated 5-Nov-15 23:18pm
v3
Comments
Krunal Rohit 6-Nov-15 5:02am    
Reformat your code.

-KR

1 solution

Best thing for refreshing partial view is to use ajax.

Create new action where you return your partial view and call it when you need it.

C#
protected ActionResult MyAction(string param)
{
    /*Some logic*/
    return PartialView("NameOfPartialView", modelForPartialView);
}


and on page something like this:

JavaScript
$.ajax({
    url: "MyActionUrl",
    data: $("#partial-view-form").serialize(),
    type: "POST",
    dataType: "html"
})
.success(function (result, status) {
    $("#my-partial-view").html(result);
    /*another logic*/
})
.error(function (xhr, status) {
    /*you logic for error*/
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900