什么是等价的"字面"标签在asp.net mvc的

编程入门 行业动态 更新时间:2024-10-25 11:31:07
本文介绍了什么是等价的"字面"标签在asp mvc的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是从asp迁移网站ASP.NET MVC

i am migrating a website from asp to asp mvc

在asp网站还有很多地方,他们有文字标签和服务器在文字标签生成一串HTML和棍棒的。

in the asp site there are many places where they have "literal" tags and the server generates a bunch of html and sticks in in the literal tag.

什么是在asp的MVC doign此相当。我应该在ViewData的推呢?

what is the equivalent of doign this in asp mvc. Should i shove this in ViewData?

推荐答案

相当于是不会犯同样糟糕的设计选择原来的开发商的。

The equivalent is to not make the same bad design choices the original developer made.

但是,因为我们生活在现实世界中,你会推自己的字符串,其中包含中,HTML到presentation型号为某一特定页面,然后将其写入响应流中。

But, since we live in the real world, you'd shove their strings-which-contain-html into the presentation model for a particular page and then write it to the response stream.

在你的模型:

public class MyPageModel { public string HolyCrapItsHtml {get;set;} }

在你的控制器:

public ActionResult MyPage() { return View(new MyPageModel {HolyCrapItsHtml = OldCode.GetHtmlICantBelieveIt()}); }

和在你的页面:

<div> In the olden days, we'd concatenate our webpages together from strings like: <%= Model.HolyCrapItsHtml %> </div>

更多推荐

什么是等价的&QUOT;字面&QUOT;标签在asp.net mvc的

本文发布于:2023-06-08 03:53:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/576147.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字面   标签   QUOT   mvc   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!