What does <%# "whatever" %> mean in ASP.NET? [duplicate]
Asked Answered
U

3

11

Possible Duplicate:
Meaning of the various symbols in .aspx page of asp.net

I'm familiar with <%= "whatever" %> as a shortcut for <% Response.Write("whatever"); %>.

But I've recently come across some code that uses <%# %> instead. In this particular codebase, it's only being used inside of an <asp:Repeater /> but I

What does <%# %> do and when can/should it be used?

Unstrung answered 2/12, 2011 at 20:33 Comment(5)
It means you're binding some data element. The repeater probably has a data source which are being repeated inside of your control.Electrochemistry
George, can you elaborate? My C#/ASP.NET skills are pretty basic.Unstrung
Data binding on a repeater control: msdn.microsoft.com/en-us/library/aa719636%28v=vs.71%29.aspxElectrochemistry
@ChrisF, thanks for pointing that one out. I think this question should be closed rather than being deleted, just to have some additional search terms available.Unstrung
Marking as duplicate doesn't delete it. It will stay open as a duplicate and alternate search result. There's at least one more I think, but I can't find it because the search for %> doesn't work!Roose
S
11

<%# ... %>

Data-binding expressions are an important set of code delimiters, which are used to create a binding between a server control property and a data source.

More about it here:

ASP.NET Code Delimiters

Slang answered 2/12, 2011 at 20:36 Comment(1)
Linked page isn't workingBaluster
N
2

Its used in conjunction with Databind.Eval as in <%# DataBinder.Eval(Container.DataItem, "Price") %>

Here is an MSDN page onthe matter

Nutshell answered 2/12, 2011 at 20:36 Comment(0)
I
1

That's how you do "BINDING" you may want to do a google search on asp.net data binding also to if you are using something like system.web.htmlcontrols this is how you could also get at document variables by name when using javascript.

Individually answered 2/12, 2011 at 20:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.