如何在asp.net代码后面给div链接 [英] how to give link to div in asp.net code behind

查看:88
本文介绍了如何在asp.net代码后面给div链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





这是我的div代码



 <   div      =  review-photo    id   =  ImageDiv     runat   =  server >  
< a href = ID = divOverAllRating2 > < img src = images / review-photo.png width = 149 height = 127 alt = photo / > < / a >
< span > 成为第一个< / span >
< a href = id = divOverAllRating3 > 添加照片< / a >
< / div >





当我点击整个div我想重定向到另一个。



在代码隐藏中,我给出这样的链接

 hrefOverAllRating2.HRef =OverAllRating.aspx?Id =+ compId; 





现在如何给出整个div的链接。



请帮帮我.....

谢谢....

解决方案

您可以按如下方式点击整个div:



您的HTML:



 <   div     id   =  abc    runat   = 服务器 >  ABCDEFG <   / div  >  





你的样式表:



 div#abc {
cursor:pointer ;
}







您的代码背后:



 abc.Attributes.Add(  onmouseup  location.href ='http://www.google.com'


hi,

this is my div code

<div class="review-photo" id="ImageDiv" runat="server">
                <a href="#" id="divOverAllRating2" ><img src="images/review-photo.png" width="149" height="127" alt="photo" /></a>
                <span>Be The First To</span>
                <a href="#" id="divOverAllRating3" >Add Photos</a>
             </div>



when I click entire div I want to redirect to anther.

In codebehind I give link like this

hrefOverAllRating2.HRef = "OverAllRating.aspx?Id=" + compId;



now how to give a link to entire div.

Please help me.....
Thank you....

解决方案

You can make an entire div clickable as follows:

Your HTML:

<div id="abc" runat="server">ABCDEFG</div>



Your stylesheet:

div#abc {
  cursor:pointer;
}




Your code behind:

abc.Attributes.Add("onmouseup","location.href='http://www.google.com'")


这篇关于如何在asp.net代码后面给div链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆