简体   繁体   中英

Server Tag is not well formed?

Before adding style to paragraph it was working fine but if i add style i am getting error like server tag is not well formed.please check out my code

<p 
    title='<%# DataBinder.Eval(Container.DataItem, "Title") %>' 
    id="P1" 
    runat="server" 
    style="top:<%# DataBinder.Eval(Container.DataItem, "Tops") %>px; left:<%#DataBinder.Eval(Container.DataItem, "Lefts") %>px; font-size:15px; color:White;">
</p>

on server bound controls, if you want to use <%#whatever%> inside of a property they must have single quotes instead of double. ie:

<asp:Label id="lbl1" runat="server" Text='<%#Eval("myvalue")%>' />

or

<p id="p1" runat="server" style='background:<%#Eval("color")%>;'>stuff here</p>

只需在样式标签周围使用单引号,即可避免与Eval部分中的双引号冲突。

style='top:<%# DataBinder.Eval(Container.DataItem, "Tops") %>px; left:%#DataBinder.Eval(Container.DataItem, "Lefts") %>px; font-size:15px; color:White;">'

try this code:

<p 
    title='<%# DataBinder.Eval(Container.DataItem, "Title") %>' 
    id="P1" 
    runat="server" 
    style='top:<%# DataBinder.Eval(Container.DataItem, "Tops") %>px; left:<%#DataBinder.Eval(Container.DataItem, "Lefts") %>px; font-size:15px; color:White;'>
</p>

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