I want to create an inline function/method inside of my user control, so that I can do this:
Inside my test.ascx:
<asp:Repeater ...>
<itemTemplate>
<p><%# MyInlineMethod(Eval("hello").ToString())%> </p>
<itemTemplate>
</asp:Repeater>
is this possible?
Yes it is possible but it has to be static method. And you will have to access it with fully qualified name or import the namespace.
<%@ Import Namespace="RootNamespace.SubNamespace1" %>
<asp:Repeater ...>
<itemTemplate>
<p><%# MyClass.MyInlineMethod(Eval("hello").ToString())%> </p>
<itemTemplate>
</asp:Repeater>
Method definition
namespace RootNamespace.SubNamespace1
{
public class MyClass
{
public static string MyInlineMethod(string input){
return string.Format("{0}!!!",input);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With