[英]I have a asp.net c# project, what is the difference between <%=myfunction(); %> & <%# myfunction() %>?
protected string myfunction() {
return "abc";
}
In one of my pages I can show the "abc"
in the webpage by using <%# myfunction() %>
. 在我的页面之一中,我可以使用<%# myfunction() %>
在网页中显示"abc"
。 But in another page it doesn't work unless I use <%=myfunction(); %>
但是在另一个页面中,除非我使用<%=myfunction(); %>
否则它将无法正常工作<%=myfunction(); %>
<%=myfunction(); %>
instead. <%=myfunction(); %>
代替。
What is the difference and why? 有什么区别,为什么?
Thanks a lot! 非常感谢!
<%= myfunction(); %>
<%= myfunction(); %>
would be used to output the return value of myfunction
in a page. <%= myfunction(); %>
将用于在页面中输出myfunction
的返回值。
<%# myfunction(); %>
<%# myfunction(); %>
would be used to output the return value of myfunction
in a control that is data bound (for example, inside an asp repeater control). <%# myfunction(); %>
将用于在绑定了数据的控件中(例如,在ASP转发器控件内部)输出myfunction
的返回值。
Take a look at this overview for more information on data binding. 请查看此概述 ,以获取有关数据绑定的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.