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

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
云风的 BLOG
云风的 BLOG
美团技术团队
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
GbyAI
GbyAI
雷峰网
雷峰网
P
Proofpoint News Feed
IT之家
IT之家
人人都是产品经理
人人都是产品经理
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
T
The Blog of Author Tim Ferriss
月光博客
月光博客
V
Visual Studio Blog
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
T
Troy Hunt's Blog
Project Zero
Project Zero
U
Unit 42
T
Tor Project blog
Scott Helme
Scott Helme
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
I
InfoQ
Cloudbric
Cloudbric
P
Proofpoint News Feed
The Cloudflare Blog
H
Heimdal Security Blog
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
Attack and Defense Labs
Attack and Defense Labs
有赞技术团队
有赞技术团队
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
J
Java Code Geeks
博客园 - 【当耐特】
Security Latest
Security Latest
The Register - Security
The Register - Security
F
Fortinet All Blogs
I
Intezer
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
NISL@THU
NISL@THU
T
Tenable Blog

博客园 - 过客匆匆

几个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);