积极答复者
img 对象如何实现响应点击事件,后台程序如何获取?

问题
-
我用下面代码,通过后台的程序,把一组图片在页面上显示出来了。
当点击任一个图片时候,希望后台程序能捕获这个事件。
并获取img 的 src的值。
请问应该如何做?
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<%#Container.ItemIndex != 0 ? (Container.ItemIndex % 6 == 0 ?"</ul><ul>" : "") : ""%>
<li>
<img src="<%# Eval("ImgPath") %>" style="CURSOR: hand" width="120" height="120"/>
</li>
</ItemTemplate>
</asp:Repeater>
答案
-
<img src="<%# Eval("ImgPath") %>" style="CURSOR: hand" width="120" height="120" onclick='Reload(this)'/>
你的javascript函数:
function Reload(content)
{
window.location = xxx.aspx?c=content.src;
}
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report- 已标记为答案 VCResearch 2013年4月24日 13:17
全部回复
-
<img src="<%# Eval("ImgPath") %>" style="CURSOR: hand" width="120" height="120" onclick='Reload(this)'/>
你的javascript函数:
function Reload(content)
{
window.location = xxx.aspx?c=content.src;
}
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report- 已标记为答案 VCResearch 2013年4月24日 13:17
-
我现在这样写的,点击图片,页面没有跳转。
<body id="top">
<form id="form1" runat="server"><script type="text/javascript">
function Reload(content)
{
window.location = xxx.aspx?pid=content.id;
}
</script>...
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<%#Container.ItemIndex != 0 ? (Container.ItemIndex % 6 == 0 ?"</ul><ul>" : "") : ""%>
<li>
<img id="<%# Eval("ImgId") %>" src="<%# Eval("ImgPath") %>" style="CURSOR: hand" width="120" height="120" onclick='Reload(this)'/>
</li>
</ItemTemplate>
</asp:Repeater> -
你测试一下这个客户端事件是否被激发了:
<script type="text/javascript"> function Reload(content) { alert("OK"); window.location = "xxx.aspx?pid="+content.id; } </script>
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report