ND's
ND's

Reputation: 2225

“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?

Upvotes: 0

Views: 478

Answers (2)

Amit Singh
Amit Singh

Reputation: 8129

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) +@""");" %>'

Upvotes: 1

Adrian Iftode
Adrian Iftode

Reputation: 15683

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

Upvotes: 3

Related Questions