读书人

asp.net C#怎么得到textbox选定的文本

发布时间: 2012-09-14 11:53:44 作者: rapoo

asp.net C#如何得到textbox选定的文本
RT
比如说这是内容
怎么得到选定的文本‘内容’?


[解决办法]
只能通过JS获取
后台要使用可AJAX来实现

JS代码
function getRangeById(id)
{
var word='';
if (document.selection){o=document.selection.createRange();if(o.text.length>0)word=o.text;}else{
o=document.getElementById(id); p1=o.selectionStart;p2=o.selectionEnd;
if (p1||p1=='0'){if(p1!=p2)word=o.value.substring(p1,p2);}}
return word;
}

读书人网 >asp.net

热点推荐