Sometimes we don't want to put Partialview directly on HTML, but instead use jquery to load dynamically, or an event to load.
In order to demonstrate and do this exercise, we first in the views directory under the home to create _partial1.cshtml partial view, the view content of any custom, insus.net in this example only to display some text and a picture:
Next, we need to create a ActionResult () method, under the Controllers directory, to open the HomeController.cs:
Then go to the Views\home directory, create a dynamicload view, and in this view, practice dynamically loading the part of the view that you created at the beginning of the article.
In the view, Insus.net only writes a DIV tag, which will be loaded later partialview.
However, because Partialview (partial views) cannot be viewed directly as views (view). Coupled with dynamic loading, we need to specify the path to a partial view, so insus.net needs to add a method Partialviewresult () to the controller:
So we can go back to that dynamicload.cshtml view and write the jquery code:
When the view is running, you can see the following effect: