如何实现鼠标移动到gridview的栏时显示提示?
比如我gridview的一个栏绑定的数据字段用“。。。”省略了。我要如何作才能实现鼠标移动到这个绑定的字段时显示整个字段的内容? --------------------编程问答-------------------- title="你的字段内容" --------------------编程问答-------------------- <asp:TemplateField HeaderText="小图片" SortExpression="ImgUrlSml"><EditItemTemplate>
<asp:textbox ID="textbox1" runat="server" Text='<%# Eval("ImgUrlSml") %>'></asp:textbox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("ImgUrlSml") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
比如这样, 要如何实现鼠标移动到Label1上时显示title或者层? --------------------编程问答-------------------- <a href="1.aspx" title="aaaaaaa">sdasdf...</a> --------------------编程问答-------------------- <asp:Label ID="Label1" runat="server" Text='<%# Bind("ImgUrlSml") %>' ToolTip=‘<%# Bind("ImgUrlSml") %>’></asp:Label>
--------------------编程问答-------------------- 试了下。, 用title没有了格式,有没有用隐藏层的例子? --------------------编程问答-------------------- 楼上的
好象是asp的形式 --------------------编程问答-------------------- 要用到javascript --------------------编程问答-------------------- 用javascript的popup就能实现了
<DIV ID="dek" CLASS="dek"></DIV>
<SCRIPT TYPE="text/javascript">
<!--
/*
Pop up information box II (Mike McGrath (mike_mcgrath@lineone.net, http://website.lineone.net/~mike_mcgrath))
Permission granted to Dynamicdrive.com to include script in archive
For this and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
Xoffset=-60; // modify these values to ...
Yoffset= 20; // change the popup position.
var nav,old,iex=(document.all),yyy=-1000;
if(navigator.appName=="Netscape"){(document.layers)?nav=true:old=true;}
if(!old){
var skn=(nav)?document.dek:dek.style;
if(nav)document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=get_mouse;
}
function popup(msg,bak){
var content="<TABLE WIDTH=150 BORDER=1 BORDERCOLOR=black CELLPADDING=2 CELLSPACING=0 "+
"BGCOLOR="+bak+"><TD ALIGN=center><FONT COLOR=black SIZE=2>"+msg+"</FONT></TD></TABLE>";
if(old){alert(msg);return;}
else{yyy=Yoffset;
if(nav){skn.document.write(content);skn.document.close();skn.visibility="visible"}
if(iex){document.all("dek").innerHTML=content;skn.visibility="visible"}
}
}
function get_mouse(e){
var x=(nav)?e.pageX:event.x+document.body.scrollLeft;skn.left=x+Xoffset;
var y=(nav)?e.pageY:event.y+document.body.scrollTop;skn.top=y+yyy;
}
function kill(){
if(!old){yyy=-1000;skn.visibility="hidden";}
}
//-->
</SCRIPT> --------------------编程问答-------------------- 我的BLOG上有一篇有详细介绍
http;//blog.csdn.net/lubosun/ --------------------编程问答-------------------- <asp:TemplateField HeaderText="小图片" SortExpression="ImgUrlSml">
<EditItemTemplate>
<asp:textbox ID="textbox1" runat="server" Text='<%# Eval("ImgUrlSml") %>'></asp:textbox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("ImgUrlSml") %>'></asp:Label>
<div><%# Bind("ImgUrlSml") %></div>
</ItemTemplate>
</asp:TemplateField>
lable1.attribute.add("onmouseover",div.display="block"); --------------------编程问答-------------------- protected void gvPrisoner_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (!Page.IsPostBack || bInEditing == false)
{
if (e.Row.DataItem == null)
return;
DataRowView drvCur = (DataRowView)e.Row.DataItem;
e.Row.Cells[1].Text = SubStr(drvCur["PrisonerNO"].ToString(), 4);
e.Row.Cells[1].ToolTip = drvCur["PrisonerNO"].ToString();
e.Row.Cells[2].Text = SubStr(drvCur["PrisonerName"].ToString(), 3);
e.Row.Cells[2].ToolTip = drvCur["PrisonerName"].ToString();
e.Row.Cells[3].Text = SubStr(drvCur["PrisonName"].ToString(), 4);
//............................
}
}
protected string SubStr(string strOldString, int iLeng)
{
if (strOldString.Length <= iLeng)
{
return strOldString;
}
string strNewString = strOldString.Substring(0,iLeng);
strNewString += "...";
return strNewString;
} --------------------编程问答-------------------- 上面的例子没没有在数据库端先截断字符,而是在数据绑定时做的处理,bInEditing用于判断是否处于编辑状态
我现在就这样用的 --------------------编程问答-------------------- 怎么没有人顶啊 !我也正需要这样的回答了!
补充:.NET技术 , ASP.NET