简体   繁体   中英

“The server tag is not well formed

javascript function

function ShowVisit(ID)
    {
       //do something with ID
    }   
       <asp:Repeater ID="repeaterPatientList" runat="server">
                <ItemTemplate>
                    <tr id="objTR" runat="server" ondblclick="return ShowVisit('<%#Eval("ID") %>')">
                    </tr>
                </ItemTemplate>
      </asp:Repeater>

When i give runat="server" to tr then error grows “The server tag is not well formed.” What's wrong?

 <tr id="objTR" 
     runat="server" 
     ondblclick=<%# "return ShowVisit('" + Eval("ID") +  "');"  %>>

ondblclick="return ShowVisit('<%#Eval("ID") %>') this interpreted by compiler as ondblclick="return ShowVisit('<%#Eval(" as fist string ID as second ") %>')" as third string. It because your double qoute start from just before return and end before ID MEANS ITS first string now there is no concatenation betwen first string and ID so it's error.Similarly for the sceond and thisd string.Your Above string is treated as same llike below..

string str="Hello"id"How are you";

To make it single string and to make work,,, You can try like this...

 ondblclick='<%#@"return ShowVisit("""+ (Eval("ID") as string) +@""");" %>'

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