Div下拉式菜单选择项
2016-06-24 17:45
218 查看
asp.net 做的一个下拉选择项
前台代码:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Spyjview.ascx.cs" Inherits="hkpro.Choose.portal.Spyjview1" %>
<style>
li{list-style-type:none;}
a:link {
font-size: 12px;
color: #000000;
text-decoration: none;
}
a:visited {
font-size: 12px;
color: #000000;
text-decoration: none;
}
a:hover {
font-size: 12px;
color: #999999;
text-decoration: underline;
}
#yjImg {
width: 0px;
height: 0px;
overflow:hidden;
border-top: 5px solid black;
border-right: 5px solid transparent;
border-left: 5px solid transparent;
border-bottom: 5px solid transparent;
}
</style>
<script src="../../easyui/jquery.min.js"></script>
<script >
$<%=this.Spyjview%> = $(document);
$(document).ready(function () {
$("#div_yj").click(function (e) { e.stopPropagation(); });
var yjL = $("#div_yj");
$(document).click(function () {
if (yjL.is(':visible')) {
yjL.hide();
}
})
$("#yjImg").click(function (e) {
e.stopPropagation();
if (!yjL.is(':visible')) {
var x=e.clientX;
var y=e.clientY;
var winW = $(window).innerWidth();
var winH = $(window).innerHeight();
var yjlW=yjL.width();
var yjlH=yjL.height();
if (x + yjlW > winW) {
x = winW - yjlW;
}
if (y + yjlH > winH) {
y = winH - yjlH;
}
yjL.css("left", x+ "px");
yjL.css("top", y+ "px");
yjL.show();
}
})
yjL.find("li").click(function (e) {
// $('#<%=this.TagetId%>').val(this.innerText);
// 点击选择项的事件
$<%=this.Spyjview%>.trigger("onSelected", [this.innerText, function () { }]);
yjL.hide();
})
})
</script>
<img src="#" id="yjImg" alt="选择系统提供的审批意见" />
<div id="div_yj" style="width:100px; height:0px; line-height:25px; position:absolute;float:initial;display:none;">
<ul runat="server" id="yjList" style="padding:0; padding-left:25px; margin:0; text-align:left; background:#DDD;">
</ul>
</div>
后台代码,初始化ul内部内容
DataTable dt= SqlHelper.ExecuteDt(strSql);
string innerHtml="";
foreach (DataRow dr in dt.Rows)
{
innerHtml += string.Format("<li><a href='javascript:void'>{0}</a></li>", dr[0]);
}
yjList.InnerHtml = innerHtml;
asp.net 做的一个下拉选择项
前台代码:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Spyjview.ascx.cs" Inherits="hkpro.Choose.portal.Spyjview1" %>
<style>
li{list-style-type:none;}
a:link {
font-size: 12px;
color: #000000;
text-decoration: none;
}
a:visited {
font-size: 12px;
color: #000000;
text-decoration: none;
}
a:hover {
font-size: 12px;
color: #999999;
text-decoration: underline;
}
#yjImg {
width: 0px;
height: 0px;
overflow:hidden;
border-top: 5px solid black;
border-right: 5px solid transparent;
border-left: 5px solid transparent;
border-bottom: 5px solid transparent;
}
</style>
<script src="../../easyui/jquery.min.js"></script>
<script >
$<%=this.Spyjview%> = $(document);
$(document).ready(function () {
$("#div_yj").click(function (e) { e.stopPropagation(); });
var yjL = $("#div_yj");
$(document).click(function () {
if (yjL.is(':visible')) {
yjL.hide();
}
})
$("#yjImg").click(function (e) {
e.stopPropagation();
if (!yjL.is(':visible')) {
var x=e.clientX;
var y=e.clientY;
var winW = $(window).innerWidth();
var winH = $(window).innerHeight();
var yjlW=yjL.width();
var yjlH=yjL.height();
if (x + yjlW > winW) {
x = winW - yjlW;
}
if (y + yjlH > winH) {
y = winH - yjlH;
}
yjL.css("left", x+ "px");
yjL.css("top", y+ "px");
yjL.show();
}
})
yjL.find("li").click(function (e) {
// $('#<%=this.TagetId%>').val(this.innerText);
// 点击选择项的事件
$<%=this.Spyjview%>.trigger("onSelected", [this.innerText, function () { }]);
yjL.hide();
})
})
</script>
<img src="#" id="yjImg" alt="选择系统提供的审批意见" />
<div id="div_yj" style="width:100px; height:0px; line-height:25px; position:absolute;float:initial;display:none;">
<ul runat="server" id="yjList" style="padding:0; padding-left:25px; margin:0; text-align:left; background:#DDD;">
</ul>
</div>
后台代码,初始化ul内部内容
DataTable dt= SqlHelper.ExecuteDt(strSql);
string innerHtml="";
foreach (DataRow dr in dt.Rows)
{
innerHtml += string.Format("<li><a href='javascript:void'>{0}</a></li>", dr[0]);
}
yjList.InnerHtml = innerHtml;
相关文章推荐
- Linux常用命令--split
- 地图与定位(六)高德地图服务二
- Bootstrap排版的类 做web前端开发的你精通吗?
- Sublimt HTML/CSS代码快速编写神器
- Yeoman创建自己的generator(1)
- Java线程中sleep()、wait()和notify()和notifyAll()、yield()、join()等方法的用法和区别
- 详细配置android studio的gradle
- java获取文件的md5值
- 14.4.3.6 Fine-tuning InnoDB Buffer Pool Flushing 微调 InnoDB Buffer Pool 刷新:
- 时间与日期的转换
- 数据库性能问题排查
- GC算法 垃圾收集器
- 14.4.3.6 Fine-tuning InnoDB Buffer Pool Flushing 微调 InnoDB Buffer Pool 刷新:
- 14.4.3.6 Fine-tuning InnoDB Buffer Pool Flushing 微调 InnoDB Buffer Pool 刷新:
- web容器启动Spring
- Java中有关File类listFiles的一个小测试
- html5标签汇总
- 使用stm32f103 PA11不能正常使用IO问题
- css的文本装饰,文本缩进,空白符,换行符使用示例
- 30:字符环