GridView 的行高

向东 2010-02-08 12:08:50
鼠标放上去 行加高 4px 移开行高 减少 4px
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#cccccc',this.style.fontWeight='';alert(this.height);this.height = parseInt(this.height)+4;");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';this.height = parseInt(this.height)+4;");

可是不行
offsetHeight 好像不可以改变
哪位高手 支援下 谢谢
...全文
184 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
vhanzhou 2012-07-06
  • 打赏
  • 举报
回复

e.Row.Attributes.Add("onmouseover", "c=this.style.height;this.style.height='80px'");
//当鼠标移开时还原高度
e.Row.Attributes.Add("onmouseout", "this.style.height=c");
向东 2010-02-08
  • 打赏
  • 举报
回复
<table border="2">
<tr height="100px" onmouseover="this.height = parseInt(this.height)+4;" onmouseout="this.height = parseInt(this.height)-4;">
<td >dfdfdf</td>
</tr>
</table>

IE7支持 可是ff不支持
我很郁闷ff
freeflying1222 2010-02-08
  • 打赏
  • 举报
回复
因为你GridView的row默认没有行高,所以取this.height就只能得到值"",parseInt("")是不行的。
加一行代码:

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
//要先给height赋值
e.Row.Attributes.Add("height", "50px");
e.Row.Attributes.Add("onmouseover",
"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#cccccc';alert(this.height);this.height = parseInt(this.height)+4;");
}
向东 2010-02-08
  • 打赏
  • 举报
回复
onmouseover="this.style.height=this.style.height-4"
这个倒是可以 可是FF不支持 IE7可以
tan124 2010-02-08
  • 打赏
  • 举报
回复
var currTR=this;
function overTR(){
var trs = document.getElementById("setTbl").getElementsByTagName("tr");
for(var i in trs){
trs[i].onmouseover = function(){
var oldBgColor=this.bgColor;
var oldFontColor=this.style.color;
this.bgColor = "#0000FF";
this.style.color="#FFFFFF";
if(currTR != this&&currTR.tagName=="TR"){currTR.bgColor = oldBgColor; currTR.style.color=oldFontColor;}
currTR = this;
}
}
}
window.onload = function(){overTR();}
wuyq11 2010-02-08
  • 打赏
  • 举报
回复

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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