asp.net 实现下拉框只读功能
asp.net 实现下拉框只读功能
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:下拉框模拟只读//根据下拉框ID设置下拉框只读functionsetReadOnly(obj_id){varobj=doc...

复制代码 代码如下:

<HTML>

<HEAD>

<TITLE>下拉框模拟只读</TITLE>

<script type="text/javascript">

//根据下拉框ID设置下拉框只读

function setReadOnly(obj_id){

var obj = document.getElementById(obj_id);

obj.onmouseover = function(){

obj.setCapture();

}

obj.onmouseout = function(){

obj.releaseCapture();

}

obj.onfocus = function(){

obj.blur();

}

obj.onbeforeactivate = function(){

return false;

}

}

</script>

</HEAD>

<BODY>

<span id="span_select">

<select id="id_select">

<option value="1">AAAAAAAAA</option>

<option value="2">BBBBBBBBB</option>

<option value="3">CCCCCCCCC</option>

<option value="4">DDDDDDDDD</option>

</select>

</span>

<script type="text/javascript">

setReadOnly("span_select");

</script>

<>

<select onbeforeactivate="return false" onfocus="this.blur()" onmouseover="this.setCapture()" onmouseout="this.releaseCapture()">

</BODY>

</HTML>

如果是ASP.NET ,则是下面的写法

复制代码 代码如下:

this.ddlSysCategory.Attributes.Add("onfocus","this.blur();");

this.ddlSysCategory.Attributes.Add("onbeforeactivate","return false");

this.ddlSysCategory.Attributes.Add("onmouseover","this.setCapture()");

this.ddlSysCategory.Attributes.Add("onmouseout","this.releaseCapture()");

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新asp.net教程学习
热门asp.net教程学习
编程开发子分类