惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Application and Cybersecurity Blog
Application and Cybersecurity Blog
B
Blog RSS Feed
M
MIT News - Artificial intelligence
爱范儿
爱范儿
V
V2EX
雷峰网
雷峰网
D
Docker
美团技术团队
N
Netflix TechBlog - Medium
C
Cisco Blogs
T
Threatpost
K
Kaspersky official blog
P
Privacy International News Feed
W
WeLiveSecurity
T
Tor Project blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 聂微东
F
Full Disclosure
Forbes - Security
Forbes - Security
V
Vulnerabilities – Threatpost
I
Intezer
有赞技术团队
有赞技术团队
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Google Online Security Blog
Google Online Security Blog
The Register - Security
The Register - Security
GbyAI
GbyAI
Security Archives - TechRepublic
Security Archives - TechRepublic
Help Net Security
Help Net Security
人人都是产品经理
人人都是产品经理
SecWiki News
SecWiki News
Cyberwarzone
Cyberwarzone
Vercel News
Vercel News
罗磊的独立博客
The Hacker News
The Hacker News
腾讯CDC
S
Security @ Cisco Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
WordPress大学
WordPress大学
Recorded Future
Recorded Future
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 【当耐特】
小众软件
小众软件
Hacker News: Ask HN
Hacker News: Ask HN
P
Proofpoint News Feed
TaoSecurity Blog
TaoSecurity Blog
IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Security Affairs
C
Check Point Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - 过客匆匆

几个Javascript函数 - 过客匆匆 - 博客园 一个在vbscript中读取cookie的程序函数 ASP2HTML WITH TEMPLET [转载] 惊云下载系统里的html文件生成方法 - 过客匆匆 - 博客园 [转载]网站生成静态页面攻略 用Visual C#打造多页面网页浏览器 嵌套使用DATAList 漫谈ASP.NET设计中的性能优化问题 ASP生成静态网页的方法 令网站打开提高速度的7大秘方 ASP.NET 格式化字符串(转) 选项卡 注册时倒计时的东西 天气预报代码 ACCESS数据库的压缩,备份,还原,下载,删除的实现 数据库存储过程分页显示 无效的 CurrentPageIndex 值 一个比较实用的大数据量分页存储过程 动态ASP网站生成HTM、HTML静态网站方法 模板生成静态页面
asp.net中让服务器端控件获得焦点
过客匆匆 · 2006-03-25 · via 博客园 - 过客匆匆

在以前asp中获得焦点很容易就实现了
如在body标签的onload加入document.all.form.onfoucs
但是今天我在asp.net中却卡住了嘿嘿.
如果textUsername为服务器控件,则

程序代码 程序代码

Page.RegisterStartupScript("focus", "<script language=javascript>document.getElementById('textusername').focus();</script>")

若为html控件,则

程序代码 程序代码

Page.RegisterStartupScript("focus", "<script language=javascript>window.Form1.textusername.focus();</script>")

晚上继续研究了下
函数

程序代码 程序代码

public void FocusNow(string str_Ctl_Name,Page page)//str_Ctl_Name是要获得焦点的控件的ID
  {
   page.RegisterStartupScript("","<script>document.forms(0)."+str_Ctl_Name+".focus(); document.forms(0)."+str_Ctl_Name+".select();</script>");
  }

调用的时候这样
FocusNow(this.TextBox1.ClientID,this);
或者
FocusNow("TextBox1",this);