Chandrashekar
6/13/2019 - 1:28 PM

MVC Partial View Tips


Place "~/assets/js/jquery-2.1.4.min.js" in the begining of page.

@section SectionName {} defined in partial view will not work in partial view as the partial views are not derived from _Layout page and only in _Layout page we render sections.
@section will work only in MainViews are it is derived from _Layout

If RenderPartial is used the PartialView is loaded along with the main view and jQuery(function ($) {} is called from Main as well as Child View(In chlid view when @section not used for scripts)

In child view use if ($('#dynamic-table').length > 0) {} to check if the element exists because this is called along with main view load and at that time child view element is not loaded