显然,可以使用<%=%>在ASP.NET Web窗体页面和视图中构造(渲染块)。
<%= "{0} is {1}","Foo",42 %>
这将使“Foo为42”。据我所知ASP.NET解析器翻译<%=%>调用到HttpResponse.Write(string)
.显然在上面的代码中,没有一对一的翻译,因为参数的数目不匹配(假设在上面的表达式中分离参数)。
现在我已经看到TextWriter
类有一个Write(string,object[])
的方法。
我已经检查了解析器的输出,实际上它调用了接受一个params对象[]参数进行格式化的TextWriter方法:
private void @__Renderform1(System.Web.UI.HtmlTextWriter @__w,System.Web.UI.Control parameterContainer) { // ... @__w.Write( "{0} is {1}",42 );
这个行为是否记录在任何地方?
解决方法
As far as I kNow the ASP.NET parser translates <%= %> into a call to
HttpResponse.Write(string).
也许<%=“{0}是{1}”,“Foo”,42%>被转换为Response.Output.Write(string format,params object [] arg),输出类型为TextWriter,这将是解释
根据http://www.hanselman.com/blog/ASPNETResponseWriteAndResponseOutputWriteKnowTheDifference.aspx
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。