zoukankan
html css js c++ java
在ASP.NET中利JavaScript实现控件的聚焦
在Windows应用程序中很容易控制控件的聚焦,但是在ASP.NET中并没有提供这样的功能,但是我们同样可以实现这样的功能,这篇文章就讲述了通过JaveScript实现在页面上某一特定控件获得焦点的功能。
下面是用到的JavaScript代码。
<
script language
=
"
javascript
"
>
var
control
=
document.getElementById(
<
control name
>
);
if
( control
!=
null
){ control.focus(); }
</
script
>
这里写了一个SetFocusControl函数来封装上面的JavaScript代码,并且注册到页面上,注册到页面上使用的是Page.RegisterStartupScript 方法
Public
Sub SetFocusControl()
Sub
SetFocusControl(
ByVal
ControlName
As
String
)
'
character 34 = "
'
注意空格的书写这里用chr(34)
Dim
script
As
String
=
_
"
<script language=
"
+
Chr
(
34
)
+
"
javascript
"
+
Chr
(
34
) _
+
"
>
"
+
_
"
var control = document.getElementById(
"
+
Chr
(
34
)
+
_
ControlName
+
Chr
(
34
)
+
"
);
"
+
_
"
if( control != null ){control.focus();}
"
+
_
"
</script>"
Page.RegisterStartupScript(
"
Focus
"
, script)
End Sub
其中的ControlName是你要获得焦点的控件的ID。
查看全文
相关阅读:
BZOJ3105 新Nim游戏 【拟阵】
Codeforces1037G A Game on Strings 【SG函数】【区间DP】
@RequestBody和@RequestParam
Swagger学习
单点登录SSO
工作流学习
Lombok
PageHelper分页插件
mybatis逆向工程介绍
跨域请求的解决方案
原文地址:https://www.cnblogs.com/chinatefl/p/165816.html
最新文章
C#正则表达式大全
Lambda表达式
jQuery的基本用法
oracle实现"limit"功能
python:类3——魔法方法
python:类2——有关类和对象的BIF内置函数
oracle:表重命名
shuf
sort
tr
热门文章
uniq
wc
tar使用笔记
Codeforces1073E Segment Sum 【数位DP】
Codeforces1063D Candies for Children 【分类讨论】【暴力】
Codeforces1071C Triple Flips 【构造】【Four Russians】
AtcoderARC062F Painting Graphs with AtCoDeer 【双连通分量】【polya原理】
Codeforces1065G Fibonacci Suffix 【递推】【二分答案】
Codeforces1065F Up and Down the Tree 【树形DP】
codeforces1045B Space Isaac 【manacher】【差分】
Copyright © 2011-2022 走看看