简体   繁体   中英

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

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

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

当您使用诸如RepeaterGridView等模板控件时,您实际上是在数据记录列表中进行迭代,并且<%# Eval("FileName") %>在这里意味着给我名为FileName的列的值。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM