求MVC关于Views调用control方法
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcApplication2.Controllers
{
public class DefaultController : Controller
{
//
// GET: /Default/
public ActionResult Index()
{
return View();
}
public HtmlString GetStr()
{
string str = "<p>21312</p>";
return new HtmlString(str);
}
}
}
@using MvcApplication2.Controllers
@model DefaultController
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@Model.GetStr()
@{Html.RenderAction("动作名", "控制器名");}
@{Html.RenderAction("GetStr", "Default");}