ASP Textbox CSS and data binding problem

I have an ASP text box and I'm trying to add a calDatePicker style along with a databinding expression inside the same CssClass attribute.

Below is an example of the code I'm trying to get. Any ideas?

<asp:TextBox ID="DateValue" CssClass='<%# ShowFieldRequired(Eval("Required"))%>  + "calDatePicker"' runat="server"></asp:TextBox>
+4
source share
2 answers

Have you tried:

CssClass='<%# ShowFieldRequired(Eval("Required"))%> calDatePicker' 

Or:

<asp:TextBox ID="DateValue" CssClass='<%# ShowFieldRequired(Eval("Required")) + " calDatePicker"%>' runat="server"></asp:TextBox>
+3
source

You are pretty close. Just move the style inside the server tag.

<asp:TextBox ID="DateValue" CssClass='<%# ShowFieldRequired(Eval("Required")) + " calDatePicker"%>' runat="server"></asp:TextBox>
+2
source

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


All Articles