mattsonnhalter mattsonnhalter - 28 days ago 20
ASP.NET (C#) Question

ASP Textbox CSS and Data Binding Expression Issue

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

Below is an example of the code I am trying to get to work. Any ideas?

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

Answer

Did you try:

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

Or:

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