关于视图的一些一些一些

  一、Action指定使用视图

public ActionResult Add(string txtName, string txtContent)
        {
            return View("Index");
            return View("~/Views/Default/BackDemo.cshtml")
            return View();
        }

  二、Action向View传递数据

  主要有四种ViewData、ViewBag和Model和TempData,其中ViewData和ViewBag共享数据。TempData和其他不共享

  三、调用另一个视图(RenderPartial)

  记录一下,@{HTML.RenderPartial("~/View/Home/List.cshtml"); },这样可以直接调用另一个页面的HTML。

  如果想在调用的这个页面进行传递参数,可以在父页面,用ViewData将参数传入,然后再调用。例如这样

  ViewData["Test"] = "ccx";
  @{HTML.RenderPartial("~/View/Home/List.cshmtl"); }

  

 

相关文章:

  • 2021-05-29
  • 2021-07-14
  • 2021-09-15
  • 2021-10-13
猜你喜欢
  • 2021-09-02
  • 2022-02-08
  • 2022-12-23
  • 2021-04-29
  • 2021-10-10
  • 2019-05-18
相关资源
相似解决方案