473,396 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

<%# tags

Are the <%..%> and <%#..%> tags *both* used in ASP.NET?
Is there a difference?

Steve
Nov 18 '05 #1
3 1130
Steve,

The <%# %> tags are used for databinding, while <%= %> are more general. The
<%# %> tend to be used to be in scope with the current databinding context -
for example the current row in a datagrid as it renders which couldn't be
addressed with plain <%= %> syntax.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web
"Steve Bywaters" <by******@bigpond.net.au> wrote in message
news:uR**************@TK2MSFTNGP10.phx.gbl...
Are the <%..%> and <%#..%> tags *both* used in ASP.NET?
Is there a difference?

Steve

Nov 18 '05 #2
Is there a reference on this... it seems a little 'fuzz'?
"Rick Strahl [MVP]" <ri********@hotmail.com> wrote in message
news:OI****************@TK2MSFTNGP12.phx.gbl...
Steve,

The <%# %> tags are used for databinding, while <%= %> are more general. The <%# %> tend to be used to be in scope with the current databinding context - for example the current row in a datagrid as it renders which couldn't be
addressed with plain <%= %> syntax.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web
"Steve Bywaters" <by******@bigpond.net.au> wrote in message
news:uR**************@TK2MSFTNGP10.phx.gbl...
Are the <%..%> and <%#..%> tags *both* used in ASP.NET?
Is there a difference?

Steve


Nov 18 '05 #3
Max
In <% you can put any code in there, dim variables, whatnot.

In <%= that's actually short for response.write, so you are limited to an
expression.

In <%# this is a databinding expression used inside the scope of a web
control (such as <asp:Repeater ) where you have a Container to use to access
the items you've bound to that particular control. What you can expose is a
DataItem -- which are your value pairs. ie <%#
DataBinder.Eval(Container.DataItem, "Name") %>

Like <%= you must supply an expression, you cannot write any code in these
blocks. If you don't use the Container class, then it's the same as saying
<%= only you're using up more resources to create the Container you didn't
use.

And of course, if you need some more code in this block, just simply write a
function that returns exactly the string you want to show:

<%# GetMyText(Container.DataItem, "Name") %>

Unfortunately, using the <%# is a late bound operation, so you're getting
ASP like performance from an ASP.NET application. Not a big deal normally,
it's still superfast, but this would be the place to look if you ever start
having performance issues.

-Max
"Steve Bywaters" <by******@bigpond.net.au> wrote in message
news:el***************@TK2MSFTNGP12.phx.gbl...
Is there a reference on this... it seems a little 'fuzz'?
"Rick Strahl [MVP]" <ri********@hotmail.com> wrote in message
news:OI****************@TK2MSFTNGP12.phx.gbl...
Steve,

The <%# %> tags are used for databinding, while <%= %> are more general.

The
<%# %> tend to be used to be in scope with the current databinding

context -
for example the current row in a datagrid as it renders which couldn't be addressed with plain <%= %> syntax.

+++ Rick ---

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: wing | last post by:
Hi, I'm now doing web programming using PHP. I need to use <?php instead of <? for PHP scripts. How do I configure PHP so that it can recognize <? as well?? Thanks in advance Wing
2
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
0
by: Arne Schirmacher | last post by:
I want to display a MySQL database field that can contain HTML markup. If I use <esql:get-string> then I get all of the database field, but all tags are escaped which is not what I want. If I use...
4
by: higabe | last post by:
Three questions 1) I have a string function that works perfectly but according to W3C.org web site is syntactically flawed because it contains the characters </ in sequence. So how am I...
18
by: Timothy Casey | last post by:
Thanks in advance... =~= Timothy Casey South Australia worloq@iprimus.com.au Formerly: casey@smart.net.au
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
14
by: laurence | last post by:
I am implementing a comprehensive image-map generator utility, so have been studying W3C HTML 4.01 Specification (http://www.w3.org/TR/html4/struct/objects.html#h-13.6) on image maps (among other...
2
by: Tom Vogel | last post by:
I'd like to use the XML Documentation Tags to comment my C# code. But many of the tags do not have any effect when I execute the "Build Comment Web Pages" menu. For example, the <list> tag gets...
7
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
14
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.