Server tags cannot contain <% … %> constructs

前端 未结 4 1546
不思量自难忘°
不思量自难忘° 2020-12-01 06:54

I am trying to use CDN for my images on the website. Problem is, sometimes I have server controls such as ImageButton, and I would like to use a class in order to fully extr

4条回答
  •  离开以前
    2020-12-01 07:06

    You can evaluate code in a server tag by creating your own Code Expression Builder. It's quite simple.

    [ExpressionPrefix( "Code" )]
    public class CodeExpressionBuilder : ExpressionBuilder
    {
        public override CodeExpression GetCodeExpression( BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context )
        {
            return new CodeSnippetExpression( entry.Expression );
        }
    }
    

    And an entry in your web.config:

    
        
            
        
    
    

    This allows you to use a syntax such as:

    
    

    Here's a full explanation: http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.aspx

提交回复
热议问题