<% =expression%> not evaluated in custom control attributes



Let's say my ASPX page codebehind has a method S() which returns a
string value (of let's say a constant "string").

If I do this (hope all these special chars make it through) on an ASPX
page:
<a href='<%=S()%>'>Link</a>

this renders as one might expect; i.e. S() is evaluated and the html
rendered will be something like:
<a href='string'>Link</a>

With a server control:
<asp:HyperLink
runat="server"
NavigateUrl='<%=S()%>'>
Link
</asp:HyperLink>

I instead get:
<a href='<%=S()%>'>Link</a>

i.e. the expression is not evaluated. This appears to be the same for
most or perhaps all attributes of most or perhaps all server controls.

I'm creating a custom control (derived from WebControl) where I would
prefer to have these expressions evaluated in attributes (or at least
some of them) before they are passed to the control. I'd imagine that
this is probably done by specifying an attribute for the control
property or perhaps for the control as a whole, as the evaluation
needs to occur prior to the attribute value being passed to the
control, which has no context for evaluation at that point.

The control in question is not data bound.

Is this possible? Is it perhaps possible with a different syntactical
construction; e.g. perhaps with <%# %>?

(VS2005, ASP.NET2.0)
.



Relevant Pages

  • Re: nested backquoting (newbie) question in Clisp
    ... (defmacro nth-expr (n &body exprs) ... The problem is not that insufficient evaluation is applied, ... compiling your construct to ELT, ... So here we are exploiting the lexical closure's ability to control ...
    (comp.lang.lisp)
  • Re: <% =expression%> not evaluated in custom control attributes
    ... instead of using this ASP expression syntax you should assign the NavigateUrl property in your code-behind file: ... With a server control: ... I'm creating a custom control where I would ... which has no context for evaluation at that point. ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: I/O in PURE and ELEMENTAL procedures in Fortran 2008
    ... That would violate what little clear semantics the language ... evaluated prior to the procedure evaluation. ... should be under the control of the user. ... no deficiencies and the other way is to make it so complicated ...
    (comp.lang.fortran)
  • Re: setting permissions / trusting company via certificate?
    ... The permission grant ... is evaluated before the control assembly is actually loaded, ... evaluation. ... also be used if you would prefer to stick with signature evidence for your ...
    (microsoft.public.dotnet.security)
  • Re: Lambda as declarative idiom
    ... >> Maybe this is too outlandish, but I see lambdas as a ... > control, delegate) ... > of evaluation, and assembling the arguments required at ... *any* free variables. ...
    (comp.lang.python)