Note that there are some explanatory texts on larger screens.

plurals
  1. PObest way for update two partial view in mvc razor
    primarykey
    data
    text
    <p>how to best way for update two partial view in mvc razor ? I need to update Multiple from an Ajax call.Here is the updated body And the work is done properly. Is this way true? Is there a better way?I've tried searching but did not see anything. I did it as follows: I am using this way : </p> <p>my view :</p> <pre><code> @using (Ajax.BeginForm("Information", "Classes", new AjaxOptions { HttpMethod = "get", })) { &lt;div id="Search"&gt; &lt;input type="text" placeholder="Search" id="txtSearch" /&gt; &lt;a id="StartSearch" href="javascript:void(0);" style="background-color: burlywood"&gt;Search&lt;/a&gt; &lt;/div&gt; &lt;select id="dropDown"&gt; &lt;option&gt;10&lt;/option&gt; &lt;option&gt;20&lt;/option&gt; &lt;option&gt;30&lt;/option&gt; &lt;/select&gt; &lt;div id="Paging"&gt; @Html.Partial("_PagingNumbers", Model.Page) &lt;/div&gt; &lt;div id="gridItems"&gt; @{ Html.RenderPartial("ClassesList", Model); } &lt;/div&gt; } &lt;script type="text/javascript"&gt; $(document).ready(function () { $("#StartSearch").click(function () { changeContent('@Model.Page.CountRecordInPage', $("#txtSearch").val()); }); $("#dropDown").change(function () { changeContent($("#dropDown").val(), '@Model.Page.TextSearch'); }); function changeContent(count, search) { var currentUrl = '/' + '@Model.Page.Controller' + '/' + '@Model.Page.ActionName'; var dataForChangeContent = { typeNo: '@Model.Page.ValueIdParametr', countryNo: '@Model.Page.CountryNo', count: count, search: search }; $.ajax({ url: currentUrl, data: dataForChangeContent, success: function (data) { $('body').html(data); } }); } }); </code></pre> <p></p> <p>partial view _PagingNumbers :</p> <pre><code>@model DGM.Common.Page &lt;script&gt; function ChangeCurrentPage(obj) { var page = $(obj).text(); GoToPage(page); } function GoToPage(page) { var dataForChangeCurrentPage = { '@Model.NameIdParametr': '@Model.ValueIdParametr', countryNo: '@Model.CountryNo', count: '@Model.CountRecordInPage', search: '@Model.TextSearch', page: page }; var urlChangeCurrentPage = '/' + '@Model.Controller' + '/' + '@Model.ActionName'; $.ajax({ url: urlChangeCurrentPage, data: dataForChangeCurrentPage, success: function (data) { $('body').html(data); var requestedUrl = this.url.replace(/[&amp;?]X-Requested-With=XMLHttpRequest/i, ""); history.pushState({ html: '' }, document.title, requestedUrl); } }); } &lt;/script&gt; &lt;div style="margin: 0 auto; text-align: center;"&gt; &lt;div style="display: inline-table"&gt; @{ var countPage = Model.CountPage; var currentPage = Model.CurrentPage; } @for (int i = 1; i &lt; countPage + 1; i++) { &lt;a class="scroll-content-item ui-widget-header" onclick=" ChangeCurrentPage(this) " href="javascript:void(0);"&gt;@i&lt;/a&gt; } &lt;/div&gt; &lt;/div&gt; </code></pre> <p>my controller :</p> <pre><code> public ActionResult Information(short No, int count = 10, int page = 1, string search = "") { var Page = new Page(); var ClassesService = new ClassesService(); var viewModeltClasses = new viewModeltClasses (); int totalCountRecord; if (string.IsNullOrWhiteSpace(search)) { totalCountRecord = ClassesService.GetCount(d =&gt; d.No == No); viewModeltClasses .AirCraftClasseses = ClassesService.GetMany(d =&gt; d.No == No, page - 1, count); } else { Page.IsSearch = true; Page.TextSearch = search; var predicateSearch = GetSearchPredicateAirCraftClasses(search, TypeSearch.Contains, No, country); var predicateOrder = GetOrderPredicateAirCraftClasses(); totalCountRecord = ClassesService.GetCountSearch(predicateSearch.Expand()); viewModeltClasses .AirCraftClasseses = ClassesService.Search(predicateSearch.Expand(), predicateOrder, page - 1, count); } viewModeltClasses .IsAllCountries = country == -1; Page.AllRecord = totalCountRecord; Page.CountPage = CommonMethods.GetCountPage(totalCountRecord, count); Page.NameIdParametr = "No"; Page.ValueIdParametr = No; Page.CountRecordInPage = count; Page.ActionName = "ClassesInformation"; Page.Controller = "Classes"; Page.CurrentPage = page; viewModeltClasses .Page = Page; return View( viewModeltClasses ); } </code></pre> <p><strong>edit :</strong></p> <p>The program works correctly. But I want to know whether this is a systematic way? I have certainly changed my body?</p> <p>I just need to change the data within the form. But it does change the way the entire body.</p> <p>If I write the following code:</p> <pre><code>$('form').html(data); </code></pre> <p>Data out of the form is repeated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload