tags:

views:

42

answers:

2

where we use <%@ %> <%= %> <%# %> etc. what else asp tags can be added in asp.net web pages?

A: 
<%@ %> - page directives, Register control
<%= %> - for the server code  
<%# %> - for the eval kind of function its also for the server code
Pranay Rana
then why this not giving any output Text='<%= DateTime.Now.ToShortTimeString() %>'
ppp
@ppp it to assign value to control form inline coding
Pranay Rana
@Rana means?? how to set lable value to current date time using this tag?
ppp
<asp:Button ID="Button1" runat="server" Text= "<%# MyValue%>" /> try this
Pranay Rana
+2  A: 

<%%> is short hand for:

<script runat="server">
</script>

Anyting inside the <% and %> is server side code.

The other variants are also shortcuts:

  • <%@%> is a page directrive
  • <%=%> is short for Response.Write
  • <%:%> is short for Response.Write, adding html encoding (introduced with .NET 4.0)
  • <%#%> is a binding expression

This page is a good reference to all these.

Oded