什么时候应该在ASP.NET控件中使用#和= [英] When should I use # and = in ASP.NET controls?

查看:82
本文介绍了什么时候应该在ASP.NET控件中使用#和=的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用ASP.NET多年,但是当使用#and =是合适的时候,我永远不会记得。

I have been using ASP.NET for years, but I can never remember when using the # and = are appropriate.

例如:

<%= Grid.ClientID %>

<%# Eval("FullName")%>

##只用于支持数据绑定的控件?

Can someone explain when each should be used so I can keep it straight in my mind? Is # only used in controls that support databinding?

推荐答案

<%=%>相当于做Response.Write )无论你放在哪里。

<%= %> is the equivalent of doing Response.Write("") wherever you place it.

<%#%>用于数据绑定,只能在支持数据绑定的地方使用(可以在页面上使用这些数据)如果您在codebehind中调用了Page.DataBind(),则控制之外的级别)

<%# %> is for Databinding and can only be used where databinding is supported (you can use these on the page-level outside a control if you call Page.DataBind() in your codebehind)

数据绑定表达式概述

这篇关于什么时候应该在ASP.NET控件中使用#和=的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆