如何让img具有超链接功能?

bestpcboy 2005-10-20 09:00:47
如何让图片具有超链接功能,而且是通过代码在后台动态加载的呢?
...全文
1070 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangyanyan 2005-10-20
  • 打赏
  • 举报
回复
HyperLink楼主没有说明条件?
cs_battleship 2005-10-20
  • 打赏
  • 举报
回复
刚才那个错了

Label1.Text = "<a href='asd.aspx'><img src='333.gif' border='0'></a>";

也可以用public变量,方法多多
cs_battleship 2005-10-20
  • 打赏
  • 举报
回复
Label1.Text = "<a href="asd.aspx"><img src="333.gif" border="0"></a>";
eyych 2005-10-20
  • 打赏
  • 举报
回复
<asp:HyperLink id=HyperLink1 Text="连接" ImageUrl="xxx.gif" runat=server></asp:HyperLink>


可以在后台动态管理、添加。
辉说慧语 2005-10-20
  • 打赏
  • 举报
回复
<a href=""><img src=""/></a>
  • 打赏
  • 举报
回复
再举一例,假设让页面滚动到顶端,不要使用锚定位<a ref="#top">的形式,这会让页面随后的服务器控件回发时出现定位问题。

可以:

with myHtmlImage
.attributes.item("onclick")="javascript:window.scrollTo(0,0)"
.styles.item("cursor")="hand"
.src="myPic.gif"
end with


如果要定位到其它任意控件,可以:

with myHtmlImage
.attributes.item("onclick")=
string.format("javascript:document.all['{0}'].focus()",otherCtrl.clientID)
.styles.item("cursor")="hand"
.src="myPic.gif"
end with

你也可以动态加载任何脚本块,例如关闭窗口、打开模态窗口、控制某些区域的隐藏等等。
  • 打赏
  • 举报
回复
外边嵌超链接可能会让图片自动出现个边框。这个边框通常需要设置链接的属性而去掉。

也可以:

with myHtmlImage
.attributes.item("onclick")="javascript:window.open('abc.aspx')"
.styles.item("cursor")="hand"
.src="myPic.gif"
end with
radio_3000 2005-10-20
  • 打赏
  • 举报
回复
用 split()函数我觉得 可以做到的
最多情况用一下 正则表达式 一定可以的!
goody9807 2005-10-20
  • 打赏
  • 举报
回复
yezie 正解
tigerwen01 2005-10-20
  • 打赏
  • 举报
回复
<asp:HyperLink id=HyperLink1 Text="连接" ImageUrl="xxx.gif" runat=server></asp:HyperLink>
smallMage 2005-10-20
  • 打赏
  • 举报
回复
支持 yezie(椰子.Net) ( )
kellyrong 2005-10-20
  • 打赏
  • 举报
回复
<asp:Label ID="lbl" Runat="server"><img id="img" src="image/095.jpg" style="WIDTH: 80px; HEIGHT: 64px"></asp:Label>
後台:
lbl.Text = "<A href=""#""><img id=""img"" src=""../images/095.jpg"" style=""WIDTH: 80px; HEIGHT: 64px""></a>"
xyunsh 2005-10-20
  • 打赏
  • 举报
回复
up
yezie 2005-10-20
  • 打赏
  • 举报
回复
<a href="asd.aspx"><img src="333.gif" border="0"></a>
cw888 2005-10-20
  • 打赏
  • 举报
回复
<input id=btn1 style="Z-INDEX: 193; LEFT: 812px; WIDTH: 20px; POSITION: absolute; TOP: 163px; HEIGHT: 20px" onclick="drawcalendar('MyCal', '', 'dateinput');" type=image
src="images/calendar.gif">

drawcalendar('MyCal', '', 'dateinput');" 为javascript函数可在在后台动态加载

7,765

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧