|
Subject:
|
javascript problem
|
|
Posted By:
|
dk6607
|
Post Date:
|
10/1/2006 2:32:49 PM
|
i'm working on an asp.net application where i have some products with images. I'm using datagrid to represent the products on the web page. Now i'd like to enlarge the images when the mouse pointer is over the image (onmouseover event - popup). I found one example where these effect is used form just one image (you have to write image source manualy like below)
onmouseover="popup('<img src=logo.gif></img>')"
Now i would like to improve these function to dynamicly dispayed images. I tryed these but i get compilation error
onmouseover="popup('<img src='<%# DataBinder.Eval(Container.DataItem, "image_name") %>'></img>')"
Can anyone help me to solve these problem!
Thanks for your answers
|
|
Reply By:
|
dparsons
|
Reply Date:
|
10/1/2006 7:20:52 PM
|
What was the compiler error?
--Stole this from a moderator
I will only tell you how to do it, not do it for you. Unless, of course, you want to hire me to do work for you.
|
|
Reply By:
|
dk6607
|
Reply Date:
|
10/2/2006 3:58:29 AM
|
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The server tag is not well formed.
|
|
Reply By:
|
dparsons
|
Reply Date:
|
10/2/2006 7:21:40 AM
|
Paste the entire server tag so i can take a look at it.
--Stole this from a moderator
I will only tell you how to do it, not do it for you. Unless, of course, you want to hire me to do work for you.
|
|
Reply By:
|
dk6607
|
Reply Date:
|
10/2/2006 11:28:02 AM
|
I have chanced a little bit the code
function popup(msg) { var content="<TABLE WIDTH='"+popwidth+"' BORDER='0' BORDERCOLOR=black CELLPADDING=1 CELLSPACING=0 "+"BGCOLOR=black><TD ALIGN='center'><img src='"+msg+"'</img></TD></TABLE>";
.... (not important)
This is the javascript function that i'm calling
<asp:HyperLink Runat=server onmouseover="popup('image.gif')" .... > WORKS
<asp:HyperLink Runat=server onmouseover="popup('<%# "../gallery/" + DataBinder.Eval(Container.DataItem, "image_name") %>')" .... > NOT WORKS
and this is the control which calls the function popup
I think the problem is the syntax of the parameter in popup function in hyperlink control, or not?
What is the right form?
|
|
Reply By:
|
dparsons
|
Reply Date:
|
10/2/2006 12:10:22 PM
|
Here is the thing, the reason your server tag is malformed is because of "../gallery/" + you can't do that. You can try 2 things:
onmouseover="popup('../gallery/" + <%# DataBinder.Eval(Container.DataItem, "image_name") %> + "'")
or
When you return your result set, append ../gallery/ to the begining of your records (which doesn't mean to change the record, just manipulate the data)
SELECT '../gallery/' + imageField as popImage from Table
what will return a column whos format is ../gallery/[image path]
hth
--Stole this from a moderator
I will only tell you how to do it, not do it for you. Unless, of course, you want to hire me to do work for you.
|
|
Reply By:
|
dk6607
|
Reply Date:
|
10/2/2006 12:15:31 PM
|
I tryed without > "../gallery/" + < and still don't works
i didn't forget to copy images in the same folder where the aspx file is!
|
|
Reply By:
|
dparsons
|
Reply Date:
|
10/2/2006 12:30:06 PM
|
When I bind items inside a datagrid I do exactly this (textbox example):
<asp:TextBox ID="txt" Text='<%# Container.DataItem("columnNane") %>' Runat=server> </asp:TextBox>
try doing this:
<asp:HyperLink Runat=server onmouseover="popup('" <%# Container.DataItem("image_name") %> +"')" runat=server>
--Stole this from a moderator
I will only tell you how to do it, not do it for you. Unless, of course, you want to hire me to do work for you.
|
|
Reply By:
|
dk6607
|
Reply Date:
|
10/2/2006 12:41:15 PM
|
Nope, still nothing.
I also bind items like you Text='<%# Container.DataItem("columnNane") %>'
'<%# "../gallery/" + DataBinder.Eval(Container.DataItem, "image_name") %>' this also works in imageUrl for example but not in javascript functions
|
|
Reply By:
|
dk6607
|
Reply Date:
|
10/2/2006 12:50:10 PM
|
I think here is the problem with >"< (to many)
|
|
Reply By:
|
dparsons
|
Reply Date:
|
10/2/2006 12:56:50 PM
|
that is a possiblity, I have never tried to DataBind inside of a javascript function (though I have handled ItemDataBound of the datagrid to add javascript functions to link buttons).
I am not sure on this one.
--Stole this from a moderator
I will only tell you how to do it, not do it for you. Unless, of course, you want to hire me to do work for you.
|