chris_techno25
chris_techno25

Reputation: 2477

Asp.net ImageUrl Webforms

this is definitely an easy question but I still don't know what exactly it is for. Can anybody tell me what ImageUrl='<%# Eval("FileName") %>' means? I still don't get the idea why we need to include %#.

Upvotes: 0

Views: 992

Answers (4)

Pankaj Dubey
Pankaj Dubey

Reputation: 824

in this Line...

ImageUrl='<%# Eval("FileName") %>'

ImageURL the attribute of your asp:ImageButton control that is used to specify the Url of the Image File to be Used

Code between '<% and %>' tags are writtent to be Executed on the Server

'#' is used to specify that the result of server side execution will be bound hear

Eval KeyWord is Used To Evaluate the perticular Column Value (that you specify ("--hear--")) from The DataSourse

Upvotes: 2

techfun
techfun

Reputation: 953

Here we have used the Eval function which is used for one way databinding. FileName is the field name you are associating. Anything that's written inside <%# %> is parsed by asp.net engine before generating the webpage source which is pure client side script and html tags. So Eval function is executed at server end by ASP.net engine.

Upvotes: 1

Mahdi Tahsildari
Mahdi Tahsildari

Reputation: 13582

When you are using a Template Control like Repeater , GridView , etc. you are actually iterating in a list of data records, and <%# Eval("FileName") %> here means give me the value of the column named FileName.

Upvotes: 1

codingbiz
codingbiz

Reputation: 26376

<%# Eval("FileName") %> is used in the context of binding data from a collection to a control. Probably the value for the imageurl is coming from a property of an object in the collection

For example, List<Photo> where Photo has a property of FileName. If you are binding that to a gridview, a repeater, etc, you'll access that property for each item in the collection when binding to such controls

Upvotes: 2

Related Questions