Reputation: 321
IS it possilbe to inline code a porperty like Font-bold of control like linkbutton?
Font-Bold="<%=(Display==1)? true:false%>"
this doesn't work.
Cannot create an object of type 'System.Boolean' from its string representation '<%=(Display==2)? true:false%>' for the 'Bold' property.
Upvotes: 3
Views: 949
Reputation: 16680
You can add this functionality with a custom ExpressionBuilder, but it doesn't come standard.
With the CodeExpressionBuilder example you can use the syntax Text="<%$ Code: DateTime.Now %>"
Upvotes: 0
Reputation: 21905
You can only do this with data binding expressions:
Font-Bold="<%# (Display==1)? true:false %>"
Note the <%# instead of the <%=
And then you have to call DataBind() on the control or one of its containers.
Upvotes: 2
Reputation: 189467
No, you can't use inline code on attributes of Runat="server" elements.
Use the PreRender event of the page. Assuming the linkbutton has ID="myLinkButton" :-
myLinkButton.Font.Bold = (Display == 1);
Upvotes: 0