Embedded Encoding Control Property

Is it possible to use inline code similar to Font-bold controls like linkbutton?

Font-Bold = "<% = (Display == 1)? True: false%>"

this does not work.

Can't create an object of type 'System.Boolean' from the string view '<% = (Display == 2)? true: false%> 'for the' Bold 'property.

+3
source share
4 answers

No, you cannot use the inline code for the attributes of the Runat = "server" elements.

Use the PreRender event on the page. Assuming the link has ID = "myLinkButton": -

 myLinkButton.Font.Bold = (Display == 1);
0
source

You can only do this with data binding expressions:

Font-Bold="<%# (Display==1)? true:false %>"

<% # <% =

DataBind() .

+2

Try using single quotes.

eg.

Font-Bold='<%....
0
source

You can add this functionality using the special ExpressionBuilder, but it is not standard.

In the CodeExpressionBuilder example , you can use the syntaxText="<%$ Code: DateTime.Now %>"

0
source

Source: https://habr.com/ru/post/1721111/


All Articles