Hi Phil,
In line express like <%= %> cannot be used in server control's
attribute/property, it can only be embeded in plain html fragment. Here is
a blog article mentioned it:
#From the Suggestion Box: Why can't you use code expressions for
properties?
http://weblogs.asp.net/leftslipper/archive/2007/01/16/Using-code-expressions
-in-properties.aspx
For your scenario, as other member suggested, you can consider define the
javascript function without parameter and manually set the variable in the
javascript function definition like below:
==========
<asp:Control OnClientClick="js_function();" />
.........
<script ....>
function js_function()
{
var param = <%= your server-side code %>
}
</script>
==================
Also, for server control property, it support two kind of inline
expresssion:
1. DataBinding expression <%# %>
You can use it to set attributes such as:
<asp:TextBox ... Text='<%# FunctionName() %>' .../>
the "FunctionName" can be defined in codebehind(public or protected),
however, to make the databind expression get executed, you need to call
"DataBind" method on the control or it s parent control.
Here is former thread I've mentioned something on this:
http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/brow
se_thread/thread/356a59a676948d03/2eec23b49e63dd96
2. There is a new feature in ASP.NET 2.0 called custom Expression Builder
#Expression Builders in ASP.NET 2.0
http://www.beansoftware.com/ASP.NET-Tutorials/Expression-Builder.aspx
#The CodeExpressionBuilder
http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionB
uilder.aspx
You can use such expression builde to embed code expression into server
control's tag to as to intialize control property with some programmtic
values.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------