zoukankan      html  css  js  c++  java
  • 每天学点MVC 【用户自定义控件】

    Asp.Net MVC2中 说到用户自定义控件,就一肚子火气,折腾过我好多回,这回总算看了点所以然

     什么都不说了,code附上

     1 情况一:通过controller创建的用户自定义控件

     2 //Controllers :TestAscx
     4 
     5  public ActionResult TestAscx()
     6         {
     7             Ascx ascx = new Ascx();
     8             return PartialView(ascx);
     9         }
    10 //View :TestAscx.ascx
    11 
    12 <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Ascx>" %>
    13 在里面可以填写你想要写的东东
    14 
    15 //调用控件
    16 View: index.aspx
    17 
    18 <% Html.RenderAction("TestAscx"); %>

     情况二:调用ASP.NET 模式的用户自定义控件,eg:footer.ascx

    Controller中不需要任何东东,只需要在需要调用的地方

    <% Html.RenderPartial("footer"); %>
  • 相关阅读:
    mysql忘记root密码解决办法
    laravel 获取所有表名
    跳转/传值(从页面到php文件)
    smarty foreach
    radio单选框
    dedecms实例化对象
    file_get_contents()
    if($a)
    bug解决思路
    git查看远程仓库地址
  • 原文地址:https://www.cnblogs.com/bingzisky/p/2320496.html
Copyright © 2011-2022 走看看