且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将html标记传递到ASP.NET用户控件中

更新时间:2023-12-06 10:46:04

在典型的WebForms控件中,HTML将自动放入MyUserControl的Controls集合中的Literal控件中.带有模板属性的控件的工作方式略有不同,但是您仍然可以通过您正在使用其名称的属性(例如MessageTemplate)以类似的方式访问此控件.

In typical WebForms controls, the HTML will be automatically put into a Literal control in MyUserControl's Controls collection. Controls with template properties work a little differently, but you may still be able to access this in a similar way through the property whose name you're using (e.g. MessageTemplate).

MVC的工作原理完全不同,我不知道是否有一种方法可以解决您所要求的问题.您可能需要考虑使用javascript来分析在客户端不起作用的情况下实际呈现给客户端的内容.

MVC works totally differently, and I don't know if there's a way to do what you're asking there. You may want to consider using javascript to analyze what actually gets rendered client-side if it doesn't work for you.