Set Visible property with server tag <%= %> in Framework 3.5

前端 未结 5 1086
礼貌的吻别
礼貌的吻别 2020-12-01 07:16

I have been working in a .NET Framework 4 project using server tags like <%=whatever %> to set the visibility of runat=\"server\" controls, like the following:

         


        
5条回答
  •  青春惊慌失措
    2020-12-01 07:47

    As for ASP.NET aspx page's inline expression. <% %> can only be used at aspx page or user control's top document level, but can not be embeded in server control's tag attribute (such as ..>). As you've found you can create custom expression builder in ASP.NET 2.0 to add your inline expression.

    BTW, another means for supplying values to server control properties in aspx inline tempalte is using <%# %> databinding expression. This is built-in supported. The only different from other inline expression is that method on the target control or its Container control.

    Steven Cheng

    Microsoft MSDN Online Support Lead

    Full post here: http://www.aspnet-answers.com/microsoft/ASP-NET/29389067/dynamically-set-a-control-property.aspx

    And workaround here: ASP.net Inline Expression Issue

提交回复
热议问题