首页 > 新闻

Asp.Net MVC 之 View

时间:2009-04-20 09:39:48  作者:ITbird  我要投稿
Linux初探欢迎您的投稿,投放方法请点击这里查看,我们会定期赠送精美小礼品给优秀的投稿作者。海纳百川 取则行远!LinuxGoo欢迎您的到来。
一、使用View Data首先要在Controller里加代码:public class ProductController : Controller{//// GET: /Product/public ActionResult Index(){ViewData["Messag......
protected virtual string GetMatch(Match m, ViewDataDictionary viewData) { if (m.Success) { string key = m.Result("$1"); if (viewData.ContainsKey(key)) { return viewData[key].ToString(); } } return string.Empty; } } }

定义一个Controller:

using System.Web.Mvc;  

  

namespace MvcApplication1.Controllers  

{  

    public class SimpleController : Controller  

    {  

        public ActionResult Index()  

        {  

            ViewData["message"] = "Hello World!";  

            return View();  

        }  

    }  

}

而页面可以写成:Views\Simple\Index.simple

<html>  

  

<head><title>Index Simple View</title></head>  

  

<body>  

  

<h1>{message}</h1>  

  

</body>  

  

</html>  

主要看{message}被解析出来了

如果您需转载 Asp.Net MVC 之 View,请注明来自LinuxGoo.com,其版权归原作者所有。请广大网友留言时遵纪守法,使用文明用语。如果您在应用中有什么问题,请在下面留言,我们会尽快解答。
来顶一下
近回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
相关文章
栏目热门