日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

Ajax实现DataGrid/DataList动态ToolTip

發布時間:2023/11/27 生活经验 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Ajax实现DataGrid/DataList动态ToolTip 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


1.建立一aspx頁面,html代碼2.cs代碼

using?System.Data.SqlClient;
using?System.IO;
protected?void?Page_Load(object?sender,?EventArgs?e)
????
{
????????
if?(!Page.IsPostBack)
????????
{
????????????BindData();
????????????
????????}

????????
if?(ID?!=?"")
????????
{
????????????GetDescriptionByID(ID);
????????}

????????
????}


????
property

????
GetDescriptionByID

????
save?image

????
BindData

????
GetDataSet 3.數據庫腳本
if?exists?(select?*?from?dbo.sysobjects?where?id?=?object_id(N'[dbo].[TestImage]')?and?OBJECTPROPERTY(id,?N'IsUserTable')?=?1)
drop?table?[dbo].[TestImage]
GO

CREATE?TABLE?[dbo].[TestImage]?(
????
[UserID]?[int]?IDENTITY?(1,?1)?NOT?NULL?,
????
[UserName]?[nvarchar]?(500)?COLLATE?Chinese_PRC_CI_AS?NULL?,
????
[Image]?[image]?NULL?,
????
[Path]?[nvarchar]?(500)?COLLATE?Chinese_PRC_CI_AS?NULL?,
????
[Type]?[nvarchar]?(20)?COLLATE?SQL_Latin1_General_CP1_CI_AS?NULL?,
????
[Description]?[nvarchar]?(2000)?COLLATE?Chinese_PRC_CI_AS?NULL?
)?
ON?[PRIMARY]?TEXTIMAGE_ON?[PRIMARY]
GO ?

<html>
?
<head>
??
<title>WebForm1</title>
??
<style?type="text/css">.logo?{?POSITION:?absolute?}.dek?{?Z-INDEX:?200;?VISIBILITY:?hidden;?POSITION:?absolute?}</style>
?
</head>
?
<body>
?
<Form?runat="server">
??
<DIV?class="dek"?id="dek"></DIV>
????
<script?language="javascript">??
????????Xoffset
=-20;
????????Yoffset
=??20;???????
????????
var??nav,yyy=-1000;
????????
var??skn=dek.style;
????????document.onmousemove
=get_mouse;
????????
????????
//ajax
????????var?xmlHttp;????????
????????
function?createXMLHttpRequest()?
????????
{
????????????
if?(window.ActiveXObject)?
????????????
{
????????????????xmlHttp?
=?new?ActiveXObject("Microsoft.XMLHTTP");
????????????}
?
????????????
else?if?(window.XMLHttpRequest)?
????????????
{
????????????????xmlHttp?
=?new?XMLHttpRequest();
????????????}

????????}

????????????
????????
function?startRequest(id)?
????????
{
????????????createXMLHttpRequest();
????????????xmlHttp.onreadystatechange?
=?handleStateChange;
????????????xmlHttp.open(
"GET",?"?ID="+id,?true);
????????????xmlHttp.send(
null);
????????}

????????
var?content;????
????????
function?handleStateChange()?
????????
{
????????????
if(xmlHttp.readyState?==?4)
????????????
{
????????????????
if(xmlHttp.status?==?200)
????????????????
{
????????????????????content
=xmlHttp.responseText;
????????????????}

????????????}

????????}

????????
//tooltip
????????function??popup(id)
????????
{
????????????startRequest(id);
????????????yyy
=Yoffset;
????????????document.all(
"dek").innerHTML=content;
????????????skn.visibility
="visible"
????????}


????????
function??get_mouse(e)
????????
{
????????????
var??x=event.x+document.body.scrollLeft;
????????????skn.left
=x+Xoffset;
????????????
var??y=event.y+document.body.scrollTop;
????????????skn.top
=y+yyy;
????????}


????????
function??kill()
????????
{
????????????yyy
=-1000;
????????????skn.visibility
="hidden";
????????}

</script>??
??
<div>
????
<asp:FileUpload?ID="FileUpload1"?runat="server"?/><br>名稱:<asp:TextBox?ID="txtUserName"
????????????runat
="server"></asp:TextBox><br>
??????描述:
<asp:TextBox?ID="TextBox1"?runat="server"></asp:TextBox><br>
????????
<asp:Button?ID="Button2"?runat="server"?OnClick="Button2_Click"?Text="保存"?/>
????
<asp:DataList?id="DataList1"
???????????BorderColor
="black"
???????????CellPadding
="1"
???????????CellSpacing
="4"?HorizontalAlign="Center"
???????????RepeatColumns
="4"
???????????RepeatLayout
="Table"
???????????runat
="server"?ShowFooter="true"?ShowHeader="true"
???????????width
="100%">
?????????
<ItemTemplate>
????????????
<%#?DataBinder.Eval(Container.DataItem,?"UserName")%><br>
????????????
<img?ID="img1"?onmouseover="popup(<%#?DataBinder.Eval(Container.DataItem,?"UserID")%>);"?οnmοuseοut="kill();"?src='<%#?DataBinder.Eval(Container.DataItem,?"Path")?%>'?height='150'/>
?????????
</ItemTemplate>
??????
</asp:DataList>????
????
</div>
????
</Form>
?
</body>
</html>

總結

以上是生活随笔為你收集整理的Ajax实现DataGrid/DataList动态ToolTip的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。