asp.net3.5 csharp: How to show HTML content in calendar tooltip?
from: http://dotnet.itags.org/web-forms/133110/

1 <% Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml">
5 <head runat="server">
6 <title>geovindu</title>
7 <style type="text/css">
8 #dhtmltooltip{
9 position: absolute;
10 width: 150px;
11 border: 2px solid black;
12 padding: 2px;
13 background-color: lightyellow;
14 visibility: hidden;
15 z-index: 100;
16 /*Remove below line to remove shadow. Below line should always appear last within this CSS*/
17 filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135);
18 }
19 </style>
20
21 </head>
22 <body>
23 <div id="dhtmltooltip"></div>
24 <script type="text/javascript">
25
26 /***********************************************
27 * Cool DHTML tooltip script- ? Dynamic Drive DHTML code library (www.dynamicdrive.com)
28 * This notice MUST stay intact for legal use
29 * Visit Dynamic Drive athttp://www.dynamicdrive.com/ for full source code
30 ***********************************************/
31
32 var offsetxpoint=-60 //Customize x offset of tooltip
33 var offsetypoint=20 //Customize y offset of tooltip
34 var ie=document.all
35 var ns6=document.getElementById && !document.all
36 var enabletip=false
37 if (ie||ns6)
38 var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
39
40 function ietruebody(){
41 return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
42 }
43
44 function ddrivetip(thetext, thecolor, thewidth){
45 if (ns6||ie){
46 if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
47 if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
48 tipobj.innerHTML=thetext
49 enabletip=true
50 return false
51 }
52 }
53
54 function positiontip(e){
55 if (enabletip){
56 var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
57 var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
58 //Find out how close the mouse is to the corner of the window
59 var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
60 var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
61
62 var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
63
64 //if the horizontal distance isn't enough to accomodate the width of the context menu
65 if (rightedge<tipobj.offsetWidth)
66 //move the horizontal position of the menu to the left by it's width
67 tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
68 else if (curX<leftedge)
69 tipobj.style.left="5px"
70 else
71 //position the horizontal position of the menu where the mouse is positioned
72 tipobj.style.left=curX+offsetxpoint+"px"
73
74 //same concept with the vertical position
75 if (bottomedge<tipobj.offsetHeight)
76 tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
77 else
78 tipobj.style.top=curY+offsetypoint+"px"
79 tipobj.style.visibility="visible"
80 }
81 }
82
83 function hideddrivetip(){
84 if (ns6||ie){
85 enabletip=false
86 tipobj.style.visibility="hidden"
87 tipobj.style.left="-1000px"
88 tipobj.style.backgroundColor=''
89 tipobj.style.width=''
90 }
91 }
92
93 document.onmousemove=positiontip
94
95 </script>
96
97 <form id="form1" runat="server">
98 <div>
99 <asp:Calendar ID="Calendar1" runat="server" OnDayRender="Calendar1_DayRender" ToolTip="werwerwer">
100 </asp:Calendar>
101 <a href="http://reference.itags.org/reference/link/?url=http://yahoo.com" onMouseover="ddrivetip('Yahoo\'s Site', 'yellow', 250)";
102 onMouseout="hideddrivetip()">Yahoo</a>
103
104 </div>
105 </form>
106 </body>
107 </html>
108
109 using System;
110 using System.Data;
111 using System.Configuration;
112 using System.Web;
113 using System.Web.Security;
114 using System.Web.UI;
115 using System.Web.UI.WebControls;
116 using System.Web.UI.WebControls.WebParts;
117 using System.Web.UI.HtmlControls;
118
119 public partial class _Default : System.Web.UI.Page
120 {
121 protected void Page_Load(object sender, EventArgs e)
122 {
123
124
125 }
126 protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
127 {
128
129 string url= e.SelectUrl;
130 e.Cell.Controls.Clear();
131
132 HyperLink link = new HyperLink();
133 link.Text = e.Day.Date.ToString();
134 link.NavigateUrl = url;
135
136 link.Attributes.Add("onMouseOver", "ddrivetip('2333', 'yellow', 250)");
137 link .Attributes .Add ("onMouseOut","hideddrivetip()");
138
139 e.Cell.Controls.Add(link);
140
141 }
142 }
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml">
5 <head runat="server">
6 <title>geovindu</title>
7 <style type="text/css">
8 #dhtmltooltip{
9 position: absolute;
10 width: 150px;
11 border: 2px solid black;
12 padding: 2px;
13 background-color: lightyellow;
14 visibility: hidden;
15 z-index: 100;
16 /*Remove below line to remove shadow. Below line should always appear last within this CSS*/
17 filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135);
18 }
19 </style>
20
21 </head>
22 <body>
23 <div id="dhtmltooltip"></div>
24 <script type="text/javascript">
25
26 /***********************************************
27 * Cool DHTML tooltip script- ? Dynamic Drive DHTML code library (www.dynamicdrive.com)
28 * This notice MUST stay intact for legal use
29 * Visit Dynamic Drive athttp://www.dynamicdrive.com/ for full source code
30 ***********************************************/
31
32 var offsetxpoint=-60 //Customize x offset of tooltip
33 var offsetypoint=20 //Customize y offset of tooltip
34 var ie=document.all
35 var ns6=document.getElementById && !document.all
36 var enabletip=false
37 if (ie||ns6)
38 var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
39
40 function ietruebody(){
41 return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
42 }
43
44 function ddrivetip(thetext, thecolor, thewidth){
45 if (ns6||ie){
46 if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
47 if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
48 tipobj.innerHTML=thetext
49 enabletip=true
50 return false
51 }
52 }
53
54 function positiontip(e){
55 if (enabletip){
56 var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
57 var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
58 //Find out how close the mouse is to the corner of the window
59 var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
60 var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
61
62 var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
63
64 //if the horizontal distance isn't enough to accomodate the width of the context menu
65 if (rightedge<tipobj.offsetWidth)
66 //move the horizontal position of the menu to the left by it's width
67 tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
68 else if (curX<leftedge)
69 tipobj.style.left="5px"
70 else
71 //position the horizontal position of the menu where the mouse is positioned
72 tipobj.style.left=curX+offsetxpoint+"px"
73
74 //same concept with the vertical position
75 if (bottomedge<tipobj.offsetHeight)
76 tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
77 else
78 tipobj.style.top=curY+offsetypoint+"px"
79 tipobj.style.visibility="visible"
80 }
81 }
82
83 function hideddrivetip(){
84 if (ns6||ie){
85 enabletip=false
86 tipobj.style.visibility="hidden"
87 tipobj.style.left="-1000px"
88 tipobj.style.backgroundColor=''
89 tipobj.style.width=''
90 }
91 }
92
93 document.onmousemove=positiontip
94
95 </script>
96
97 <form id="form1" runat="server">
98 <div>
99 <asp:Calendar ID="Calendar1" runat="server" OnDayRender="Calendar1_DayRender" ToolTip="werwerwer">
100 </asp:Calendar>
101 <a href="http://reference.itags.org/reference/link/?url=http://yahoo.com" onMouseover="ddrivetip('Yahoo\'s Site', 'yellow', 250)";
102 onMouseout="hideddrivetip()">Yahoo</a>
103
104 </div>
105 </form>
106 </body>
107 </html>
108
109 using System;
110 using System.Data;
111 using System.Configuration;
112 using System.Web;
113 using System.Web.Security;
114 using System.Web.UI;
115 using System.Web.UI.WebControls;
116 using System.Web.UI.WebControls.WebParts;
117 using System.Web.UI.HtmlControls;
118
119 public partial class _Default : System.Web.UI.Page
120 {
121 protected void Page_Load(object sender, EventArgs e)
122 {
123
124
125 }
126 protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
127 {
128
129 string url= e.SelectUrl;
130 e.Cell.Controls.Clear();
131
132 HyperLink link = new HyperLink();
133 link.Text = e.Day.Date.ToString();
134 link.NavigateUrl = url;
135
136 link.Attributes.Add("onMouseOver", "ddrivetip('2333', 'yellow', 250)");
137 link .Attributes .Add ("onMouseOut","hideddrivetip()");
138
139 e.Cell.Controls.Add(link);
140
141 }
142 }
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)
分类:
CSharp code
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!