Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

<%# IsEditable %> and <%= IsEditable %>

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Max2006 - 13 Sep 2007 18:36 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.