Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand the partial view in MVC3

Shulou Source: shulou.com Published: 2022-06-02 03:46:03 09月30日 Update

How to understand the partial view in MVC3? I believe many inexperienced people don't know what to do about it. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

The partial view of MVC3 is equivalent to the user control of webform

1, create a new controller PartialController.cs

2. Create a new view (when you create a new view, select create as a partial view in the pop-up box) Message.cshtml, and put this file in the Views/Shared folder (convention takes precedence over configuration)

3, reference in the view (Store/Index.cshtml)

-Controller (PartialController.cs)

Using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;namespace MusicStore.Controllers {public class PartialController: Controller {/ GET: / Partial/ public ActionResult Index () {return View ();} public ActionResult Message () {return PartialView (); / / return partial view}

-partial View (Message.cshtml)

I'm the division view.

-View (Index.cshtml)

@ {ViewBag.Title = "Index";} Index@Html.Partial ("Message") $(function () {$("# a") .load ('/ Partial/Message');})

After reading the above, have you mastered how to understand the partial view in MVC3? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Views divisions content controllers files methods more problems controls helpless for this reason for this skills controls folders time users articles experience Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MySQL Redmi Shulou Information Microsoft