学习笔记

来源:互联网 发布:centos下安装jdk1.7 编辑:程序博客网 时间:2024/05/21 11:24

有时候我们需要对超链接<a href="路径" title="提示文字">链接文字</a>里边的提示文字使用换行(即需要多行提示),可是title,alt之类里边的提示内容是不支持HTML书写的,怎么解决?

-------用&#xa或者&#xd或者&#10或者&#13代替换行就可以了

eg:

<a href="Item.aspx"  title="标题: 跳转&#xd;作者: lily&#xd;时间: 2008-08-25">hello</a>

<asp:Button ID="btnSearch" runat="server" ToolTip="title:hello&#10;time: 2008-08-25"  Text="search" OnClick="btnSearch_Click" />

---------------------------------------------------------------------------------------------

在gridview 中,经常会需要一种这样的效果,当鼠标放在某一行时,某一行有一个CSS效果,当鼠标移开

该行时,又有另外一个效果,这其实就是利用了onmouseover  and  onmouseout的效果,实现起来其实很简单,

在gridview的row_databound事件中这样实现就可以了
   protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)

{

e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='blue'");//鼠标经过、到达时

e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'");//鼠标离开时

}

}

--------------------------------------------------------------------------------------------------

悬停定义为用户指示了一个元素但没有将其激活。对此最常见的例子是将鼠标指针移到 HTML 文档中一个超链接的边界范围内

a:link   {color:   #FF0000;   text-decoration:   none}   /*   未访问的链接   */  
  a:visited   {color:   #00FF00;   text-decoration:   none}   /*   已访问的链接   */  
  a:hover   {color:   #FF00FF;   text-decoration:   underline}   /*   鼠标在链接上   */  
  a:active   {color:   #0000FF;   text-decoration:   underline}   /*   激活链接   */   

 

注释:为了产生预期的效果,在 CSS 定义中,a:hover 必须位于 a:link 和 a:visited 之后!!

注释:为了产生预期的效果,在 CSS 定义中,a:active 必须位于 a:hover 之后!!

text-decoration :链接的下划线属性

eg:

<style type="text/css">
        .one { color:red; text-decoration:none }
        .one:hover { color:blue;font-size:150% ;text-decoration:underline}
    </style>
  <a href="Item.aspx" class="one" title="标题: 跳转&#xd作者: lily&#xd时间: 2008-08-25">hello</a>

---------------------------------------------------------------

对于普通 HTML 元素的title换行,至少可以有可以两种方式:

1。将title的文本分行写

<a href="#" title="hello
world">hello world</a>
2。插入换行符号 (建议采用这种方式)

<a href="#" title="hello&#10;world">hello world</a>
或者
<a href="#" title="hello&#13;world">hello world</a>
10与13分别是换行符与回车符的ASCII十进制值
 
如果需要对WebControl设置title(其实是tooltip属性)这两种方法都失效了,
而是只需要插入编程语言内置的换行符,比如C# 插入 /n

<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink>


HyperLink1.ToolTip = "hello/nworld";

如果还是输入&#10;或者&#13;asp.net会自动将&编码成 &amp; 。

这只是个小技巧,如果不注意搞上半天都搞不出效果出来

-------------------------------------------------------------------------------------------

javascript 实现热键

---------------------------------------------

<script language="javascript" type="text/javascript">
        document.onkeydown=myfunction;
        function myfunction()
        {
            var e=event.srcElement; //事件对象
            if(e!=document.getElementById("txtRemark") && event.ctrlKey && event.keyCode == 13)
            {
                //event.keyCode=0;
                //event.returnValue=false;
                document.getElementById("btnSearch").click();//触发查询按钮事件
                return false;
            }
           
        }
    </script>

 

<asp:Button ID="btnSearch" runat="server" ToolTip="title:hello &#xd;time: 2008-08-25"  Text="search" OnClick="btnSearch_Click" />

原创粉丝点击