Click here to Skip to main content
15,904,822 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
<asp:Image ID="Img1" runat="server" style="cursor:pointer;" ImageUrl='<%# Eval("photoLink1") %>' onmouseover="Tooltip(true,'<%# Eval(itemname1) %>',event);" />


when run this line it throws an error as "The server tag is not well formed".

please help me in this.

Any solution to this problem.

Thanks in advance.
Posted
Updated 19-May-11 18:53pm
v3
Comments
Member 9379538 11-Jan-13 6:18am    
<li><asp:Image ID="Img1" ImageUrl=’<%#Eval("Image")%>’ runat="server" Height="200px" Width="150px" />
<br />
<%#Eval("StudentName")%>
</li>

when run this line it throws an error as "The server tag is not well formed".

The problem is in your Eval on the onmouseover

onmouseover="Tooltip(true,'<%# Eval(itemname1) %>',event);" />


should be

onmouseover='Tooltip(true,"<%# Eval("itemname1") %>",event);' />
 
Share this answer
 
v2
Comments
arindamrudra 5-Jul-11 5:26am    
Thanks a lot. Always I will keep your suggestion in mind.
You missed double quotes for itemname1 in onmouseover.

Try:
XML
<asp:Image ID="Img1" runat="server" style="cursor:pointer;" ImageUrl='<%# Eval("photoLink1") %>' onmouseover="Tooltip(true,'<%# Eval("itemname1") %>',event);" />


Few discussion that might help:
ASP.NET ItemTemplates, EVAL() and embedding dynamic values into controls[^]
Image Url Eval - Similar discussion[^]
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 20-May-11 23:17pm    
I see, a 5.
--SA
Attribute ImageUrl must be in quotation marks "", as all other XML attributes.

—SA
 
Share this answer
 
v2
Comments
rahkan 20-May-11 0:40am    
attributes can be surrounded with either double or single quotes, but when you're embedding a server tag that includes a string that uses double quotes, like with Eval, then you need to make sure the attribute is defined with single quotes.
Sandeep Mewara 20-May-11 0:52am    
I guess that's ok SA. See my answer.
as per my experiance such things could be done this way...
1) it get you rid of lots of escape sequencing stuff..
2) gives you better flexibility on what you doing
3) more redable and managable by other programmers
4) you can check for nulls etc..

I personally always do such things in a function on server side and then call it in aspx page like

<br />
onmouseover = <%# GetToolTipFunction(Eval("Iitemname")) %><br />


in my code behind

<br />
  protected string GetToolTipFunction(object itemname)<br />
  {<br />
      // do any other stuff, like checking nulls etc...<br />
      String functionStr = "Tooltip(true,"+ itemname.ToString() + ",event)";<br />
      return functionStr;<br />
  }<br />


it may look like 2 lines of more code, but trust me it will make your life much easier in long run.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900