9

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

1

2 Answers 2

15

<%%> 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.

Sign up to request clarification or add additional context in comments.

Comments

0
<%@ %> - page directives, Register control
<%= %> - for the server code  
<%# %> - for the eval kind of function its also for the server code

3 Comments

then why this not giving any output Text='<%= DateTime.Now.ToShortTimeString() %>'
@ppp it to assign value to control form inline coding
@Rana means?? how to set lable value to current date time using this tag?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.