开发者

How can I update a model in the view with ajax?

开发者 https://www.devze.com 2023-04-13 04:09 出处:网络
Here is a portion of my code: @foreach (var item in Model) { <div class=\"ticket-overview\"> <ul>

Here is a portion of my code:

@foreach (var item in Model) {

<div class="ticket-overview">
    <ul>
     <li class="ticket-data-activity">
                <a href="#" class="ticket-open-details">
          @{
             String desc = item.Description.ToString();
           if (desc.Length > 20)
                       {
              desc = desc.Substring(0, 20);
                        }
                        @desc
                    }
                 </a>
</li>

I have this view which shows a model from a controller. Now I want to update that model with a ajax call. The view would remain the same, just the model should change.

Is it possible? If yes, how开发者_如何学Python? Give me some idea. Ask if any clarification of the question is needed, as I'm a new user and not an expert in asking.

clarification: It's actually an unordered list which is built like a custom table. Say, I want to go the next page, so I've a button to be clicked on. Then the table data should be updated. Hence the model needs to be updated.

Thanks...


Define a div to update. USe jQuery directly via .get() or .ajax(), or Ajax.BeginForm to call a controller See: Using Ajax.BeginForm with ASP.NET MVC 3 Razor

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号