Solved

What's the difference between <% %> and <%# %> ???

Posted on 2008-10-23
1
244 Views
Last Modified: 2012-05-05
Hello,

Could some one explain me what's the difference between:

<% ... some asp.net code %>

and

<%# ... some asp.net code %>

What's the # for?

Thanks in advance.
0
Comment
Question by:richardhaeger
1 Comment
 
LVL 16

Accepted Solution

by:
GreymanMSC earned 100 total points
ID: 22790976
The first simply executes inline ASP code at that point in the HTML rendering.  It is generally placed in innerHTML, as if it were an HTML tag in its own right.
The second performs databinding on Eval() or Bind() calls.  It is generally placed in the value of an attribute  of an ASP control, that itself is inside a Databound Container Control, and the # symbol escentially means: bind the result of this code to the value of the control attribute containing it.

<% If Me.chkSayHellow.Checked Then Response.Write('Hello World') %>
 
<asp:Label ID=lblWhatAmI runat=server Text='<%# Eval('WhatAmI') %> />

Open in new window

0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question