Hi,
When I use this tag:
<asp:lable . Visible='<%# IsEditable %>'
I have to do DataBind so the binding takes place.
I am trying to use the following notation to do the similar thing without
forced to call DataBind method:
<asp:lable . Visible='<%= IsEditable %>'
But I receive this error:
Generation of designer file failed: Cannot create an object of type
'System.Boolean' from its string representation '<%= IsEditable %>' for the
'Visible' property.
Is there any way to use <%= IsEditable %> instead of <%# IsEditable %> to
avoid calling the DataBind?
Thank you,
Max
Teemu Keiski - 13 Sep 2007 18:43 GMT
<%=expression%> is executed at render-time, and is meant to output literal
stuff, not to set property values. You certainly could set it in code, but
it removes completely the point of using separate variable.

Signature
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
> Hi,
>
[quoted text clipped - 21 lines]
>
> Max
Max2006 - 13 Sep 2007 18:54 GMT
Thank you for help.
Do you know any resource that allows me monitor - or spy into - when / how
these bindings happen?
If you know any online resource that explains the depth of the binding in
ASP.NET, that would be really helpful. I like to know binding beyond the
syntaxes.
Thank you,
Max
> <%=expression%> is executed at render-time, and is meant to output
> literal stuff, not to set property values. You certainly could set it in
[quoted text clipped - 25 lines]
>>
>> Max
Teemu Keiski - 13 Sep 2007 19:04 GMT
Now that we are discussing about expressions, something like that could in
fact help you: http://msdn2.microsoft.com/en-us/library/d5bd1tad.aspx

Signature
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
> Thank you for help.
>
[quoted text clipped - 37 lines]
>>>
>>> Max
bruce barker - 13 Sep 2007 22:53 GMT
no.
<%= expression %> is translated to:
Controls.Add(new Label(expression));
where <asp:label id=lb1 Visible=<%=expression%> /> is translated to:
lb1 = new Label();
lb1.Visible = "<%=expression%>";
and when databind is called, it checks for properties with binding
expressions, evals the expression, and sets the property to the value.
-- bruce (sqlwork.com)
> Hi,
>
[quoted text clipped - 21 lines]
>
> Max
Max2006 - 14 Sep 2007 14:35 GMT
Thanks Bruce for reply.
At this point, the outcome of <asp:label id=lb1 Visible=<%=expression%> />
is the error I mentioned. It doesn't work!
> no.
>
[quoted text clipped - 37 lines]
>>
>> Max
Walter Wang [MSFT] - 17 Sep 2007 02:19 GMT
Hi Max,
lbl1.Visible = "<%= expression %>";
is not a data binding expression, that's why it doesn't work.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Walter Wang [MSFT] - 14 Sep 2007 05:06 GMT
Hi Max,
A tip on inspecting the generated class from a WebForm is to first
precompile the website and use Reflector
(http://www.aisto.com/roeder/dotnet/) to view the source code of the
WebForm:
aspnet_compiler -v / -p c:\projects\website1 c:\temp\website1
reflector c:\temp\website1\bin\*.dll
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.