tags:

views:

298

answers:

8

I am new to ASP.Net and I'm a little confused here.

While learning ASP.Net through some of the articles online, I notice some of the experts using some keywords for binding data and auto incrementing a date in source code, like <%#Container.DataItemIndex + 1 %>, <%#Eval("Itemid")%>, <%#DataBinder.Eval(Container.DataItem, "itemStock")%> or <%=sectionId%>.

What are theese constructs called and where can I get the list of such keywords with an explanation?

+2  A: 

Hi, these are generally known as inline tags, take note as there are quite a few different types.

You can find a detailed explanation of each type here:

http://naspinski.net/post/inline-aspnet-tags-sorting-them-all-out-(3c25242c-3c253d2c-3c252c-3c252c-etc).aspx

OR

http://forums.asp.net/p/1049167/1478431.aspx#1478431

Dal
Server Side Scripting Delimiters (from MSDN: http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/iisbook/c06%5Fasp%5Fserver-side%5Fscripting.mspx?mfr=true)
Wolfwyrd
A: 

The ASP.NET tag syntax is fully documented in MSDN, with code examples and links to the relevant objects and methods involved. Fire up MSDN and search for these in the index:

<%#
<%$
<%@
<%=
Christian Hayter
+1  A: 

They are server side scripting delimiters. There is a full explanation here already:

http://stackoverflow.com/questions/649428/asp-net-special-tags/649458#649458

Wolfwyrd
A: 

@rahul, I think you seriously need to read through some books about ASP.net, to understand these basic things.

the symbol <% %> is used to put .net stuff into markup which is evaluated and replaced with the results of the expression.

the term <%# Container.DataItemIndex + 1 %> means that put index of the current item being bound in DataGridView etc after adding one to it. The container is the object used to display data like grid, data-list etc.

the term <%#Eval("Itemid")%> means from the object (table, custom object etc) get value of Itemid column or property.

the term <%# DataBinder.Eval(Container.DataItem, "itemStock")%> do the same thing as above but is somewhat older.

term <%=sectionId%> will ouput protected or public variable sectionId defined in code-behind file in html markup.

TheVillageIdiot
Yeah, its probably worth getting a book on Beginning ASP.NET to get to grips with the technology. I generally find web tutorials are OK for specific things, but don't give you the full scope of the technology like a book does.
Dal
A: 

These keywords are usualy known as 'blind method'. You can have more information: GoodLink

DreamWalker
A: 

I think they're refereed to as expressions.

They're actually very powerful, and can be customised.

Kieron
A: 

These keywords are known as Expressions.

They help us to set information into page when run time.For example if you define width of some panel, you can place it into web.config as application setting so that page can read its value from there,meaning value is dynamic.

Also you can access code page with declaring <%#,<%$,<%= tags so you can access page properties etc.

There are lots of documentation and you can define custom expressions like Eval,Bind etc.

Source list:
Five Undiscovered Features on ASP.NET
ASP.NET Extensibility
Express yourself with Custom Expression Builders

Myra
+1  A: 

Also know as Bee-Stings:
http://stackoverflow.com/questions/517721/in-asp-net-what-is-the-difference-between-and

  • <%@ - Page/Control/Import/Register directive
  • <%$ - Resource access and Expression building
  • <%= - Explicit output to page, equivalent to <% Response.Write( ) %>
  • <%# - [Data Binding.][1] It can only used where databinding is supported, or at the page level if you call Page.DataBind() in your code-behind.
  • <%-- - Server-side comment block
Joel Coehoorn