views:

426

answers:

4

Hi,

I wanna learn advanced and basic things about Asp.net inline scripting like

<img src="<%= Page.ResolveUrl("~")%>Images/Logo.gif"/>

or

<asp:Label ID="lblDesc" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Description")%>'></asp:Label>

and so on...

and like what's the difference between <% %> and <%# %> and such stuffs.

Could you please tell me where I can find from basic to advanced implementing of those usages.

Thanks in advance.

+4  A: 

Check out this article for the specifics of the different inline tag options.

From the article:

<% ... %> -- The most basic inline tag, basically runs normal code:

<%= ... %> -- Used for small chunks of information, usually from objects and single pieces of information like a single string or int variable:

<%# ... %> -- Used for Binding Expressions; such as Eval and Bind, most often found in data controls like GridView, Repeater, etc.:

<%$ ... %> -- Used for expressions, not code; often seen with DataSources:

<%@ ... %> -- This is for directive syntax; basically the stuff you see at the top your your aspx pages like control registration and page declaration:

<%-- ... %> -- This is a server side comment, stuff you don't want anyone without code access to see:

Matthew Vines
The best and most suitable answer came from you. Thanks for understanding me :)
Braveyard
+1  A: 

Have you searched SO?

Where can I Find GOOD ASP.NET tutorial(or books) online?

Awesome ASP.Net and C# tutorials for beginner

Not directly related, but contain good advice:

Scott Guthrie's Blog

Hidden Features of ASP.NET

Mitch Wheat
+1  A: 

Startup http://quickstarts.asp.net/QuickStartv20/aspnet/Default.aspx

Get video Tutorials from here http://www.asp.net/learn/

starter project kit http://www.asp.net/community/projects/

Application Architechure.. http://www.codeplex.com/AppArchGuide
Basic video.... for new commer.. http://www.asp.net/get-started/

Muhammad Akhtar
+1  A: 

In general, <%#..%> is used for preprocessing a template, such as when databinding, whereby the names of properties of the objects are not known at compile-time. If, for example, you have an ASP.NET Repeater object, and you databind a list of objects to it, this notation is used to pre-populate values that could not be set at any point except during the databind lifecycle.

The other notations, <%..%> and <%=..%> are more standard and you'll see these far more often than the other syntax previously discussed, especially if you use something like ASP.NET MVC instead of ASP.NET Web Forms. The syntax <%..%> executes arbitrary script inline, and nothing more, but allows you to write entire blocks of .NET code such as if statements, while loops, for loops, etc. The syntax <%=..%> is an evaluate-and-write syntax, and is rough equivalent of <% Response.Write([..].ToString()) %>. I.e., <%= myVal %> is the same as <% Response.Write(myVal.ToString()) %>

These syntaxes are basic ASP.NET knowledge.

stimpy77