using repeater data for a texbox attribute

Posted on 2012-09-03
Last Modified: 2012-09-08

I have a textbox within a repeater:
<asp:TextBox ID="txtActionStartDate" CssClass="actionStartDate<%#DataBinder.Eval(Container.DataItem, 'ID')%>" runat="server"></asp:TextBox>

Open in new window

As you can see I am trying to set a css class containing a dynamic value.

I'm getting:
The server tag is not well formed.

How can I do this?
Question by:scm0sml
    LVL 49

    Expert Comment

    by:Julian Hansen
    Try this
    <asp:TextBox ID="txtActionStartDate" CssClass="actionStartDate<%=DataBinder.Eval(Container.DataItem, 'ID')%>" runat="server"></asp:TextBox>

    Open in new window


    Author Comment

    thats actually rendering the code as text:
     class="actionStartDate<%=DataBinder.Eval(Container.DataItem, 'ID')%>" type="text"

    Accepted Solution

    i added it dynamically in the code behind:
    txtActionStartDate.Attributes.Add("class", "actionStartDate" + liveLog.ID.ToString());

    Author Closing Comment

    got my own solution in the end.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now