See my answer to a different question here. I believe you can accomplish what you want using a custom ExpressionBuilder similar to
/// <summary>
/// An Expression Builder for inserting raw code elements into ASP.NET markup.
/// Code obtained from: http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.aspx
/// </summary>
[ExpressionPrefix("Code")]
public class CodeExpressionBuilder : ExpressionBuilder
{
/// <summary>
/// Inserts the evaluated code directly into the markup.
/// </summary>
/// <param name="entry">Provides information about the expression and where it was applied.</param>
/// <param name="parsedData">Unused parameter.</param>
/// <param name="context">Unused paramter.</param>
/// <returns>A <see cref="CodeExpression"/>.</returns>
public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
return new CodeSnippetExpression(entry.Expression);
}
}
Your markup would then look like:
<asp:LinkButton ... OnClientClick=
"return confirm('Are you sure you want to remove Contract
Period <%$ Code: ContractPeriod_N.Text %>?');" />