asp.netvb.netasprepeater

Set active image in repeater VB.net


Greeting!

Without further a do, how do I set Image to active, because I get warning within this one:

Gallery.aspx

<div id="myCarousel" class="carousel slide" data-ride="carousel">
    <div class="carousel-inner" role="listbox">
    <asp:Repeater ID="Rgallary" runat="server">
    <ItemTemplate>


         <div class="item <%#(Container.ItemIndex == 0 ? "active" : "") %> "> //Expression expected.
            <asp:Image ID="imgId" runat="server" ImageUrl='<%# Bind("GalleryImg", "Image/05 Galeri/{0}") %>' /> 
        </div>

    </div>

    </ItemTemplate>
    </asp:Repeater>

    <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left"></span>
        <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right"></span>
        <span class="sr-only">Next</span>
    </a>

    </div>

It's trivial tho but I can't figure it how?


Solution

  • You seem to be writing C# even though you say your program is VB.Net?

    This is C# code that you use:

    Container.ItemIndex == 0 ? "active" : ""
    

    Use VB.Net instead:

    <div class="item <%#If(Container.ItemIndex = 0, "active", "") %>">