简体   繁体   中英

The Server tag is not well formed error in a Wizard

I am getting the "The Server tag not well formed error". Please see the below code:

<ul id="wizHeader">
               <asp:Repeater ID="SideBarList" runat="server">
                   <ItemTemplate>

                       <li>
                           <asp:LinkButton runat="server" CssClass="<%# GetClassForWizardStep(Container.DataItem) %>" Font-Bold="true" ID="SideBarButton" OnClick="Step_Click" Text="<%# Eval("Name") %>" ToolTip="<%# Eval(ID) %>"></asp:LinkButton>
                       </li>

                   </ItemTemplate>
               </asp:Repeater>
           </ul>

You can't use <%# inside of server controls' attribute.

So if you want to use a LinkButton inside of the Repeater, you have to bind the attributes in code-behind using the Repeater.ItemDataBound event.

Example from MSDN: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.itemdatabound(v=vs.110).aspx

Alternatively you can use a simple anchor tag and apply all bindings to it. And make it cause the same postback as your button was doing. Example:

   <a onClick="javascript:__doPostBack('<%= SideBarButton.UniqueID %>')" class="<%# GetClassForWizardStep(Container.DataItem) %>"> <%# Eval("Name") %></a>

After doing this, you would have to hide the link button by settings its css display property none.

Long work around. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM