Re: <% =expression%> not evaluated in custom control attributes
- From: "Rick Strahl [MVP]" <rickstrahl@xxxxxxxxxxx>
- Date: Mon, 25 Dec 2006 14:44:53 -1000
<%# %> expressions require databinding and can only be used inside of templates or inside of a full attribute value of a control. But the databinding is required as these expressions generate databinding event code.
<%= %> doesn't work inside of server control attributes as you found out because the server control parsing will interpret the expression as a string. Outside of quotes the the quotes but inside of the server expression they are not allowed at all.
As Axel points out the better way to do this is to use codebehind to set the value and while I don't agree about the 'obsolete' comment he makes, in this case that may be the only way that you can get this to work...
+++ Rick ---
"James Hawkins" <not@xxxxxxxxxxxx> wrote in message news:6i80o2935errerrbcnf98d9d96fit77rjo@xxxxxxxxxx
On Wed, 13 Dec 2006 15:38:39 GMT, James Hawkins <not@xxxxxxxxxxxx>
wrote:
The control in question is not data bound.
Is this possible? Is it perhaps possible with a different syntactical
construction; e.g. perhaps with <%# %>?
I noticed that I can use <%#S()%>, but only if I call DataBind() on
the control. As this is a custom control that I don't want to have to
explicitly DataBind(), I am currently doing a 'self-bind' by calling
DataBind() in the control's OnInit(). Is this an acceptable way of
doing things?
Thanks.
.
- References:
- <% =expression%> not evaluated in custom control attributes
- From: James Hawkins
- Re: <% =expression%> not evaluated in custom control attributes
- From: James Hawkins
- <% =expression%> not evaluated in custom control attributes
- Prev by Date: RE: Validator message disappeared after post back
- Next by Date: Problem: design time links between custom server controls.
- Previous by thread: Re: <% =expression%> not evaluated in custom control attributes
- Next by thread: Re: <% =expression%> not evaluated in custom control attributes
- Index(es):
Relevant Pages
|
Loading