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

推荐订阅源

T
Tailwind CSS Blog
C
CERT Recently Published Vulnerability Notes
P
Proofpoint News Feed
Vercel News
Vercel News
博客园 - 三生石上(FineUI控件)
IT之家
IT之家
Help Net Security
Help Net Security
月光博客
月光博客
N
News and Events Feed by Topic
Cloudbric
Cloudbric
博客园 - 司徒正美
L
LangChain Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tenable Blog
The Register - Security
The Register - Security
The Hacker News
The Hacker News
I
InfoQ
The Last Watchdog
The Last Watchdog
MyScale Blog
MyScale Blog
Schneier on Security
Schneier on Security
WordPress大学
WordPress大学
小众软件
小众软件
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
宝玉的分享
宝玉的分享
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
K
Kaspersky official blog
L
LINUX DO - 热门话题
N
News | PayPal Newsroom
F
Fortinet All Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Security @ Cisco Blogs
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
Google Online Security Blog
Google Online Security Blog
S
Schneier on Security
C
Cisco Blogs
N
News and Events Feed by Topic
V2EX - 技术
V2EX - 技术
Latest news
Latest news
PCI Perspectives
PCI Perspectives
T
The Blog of Author Tim Ferriss
P
Palo Alto Networks Blog
T
Tor Project blog
Project Zero
Project Zero
云风的 BLOG
云风的 BLOG
Webroot Blog
Webroot Blog
Attack and Defense Labs
Attack and Defense Labs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org

博客园 - IMustDo

Delphi TWebBrowser编程简述(转帖) delphi 如何将XML格式的字符串导入ClientDataSet中 用WebBrowser实现HTML界面的应用 delphi TStringList的用法 使用VSS 的Shadow folder的一点问题 Delphi 字符串操作 delphi 最快速编码 URLDecode URLEncode Delphi 2007 如何安装控件 Javascript+xmlhttp调用Webservice以及注意事项 .NET 3.5和VS 2008中的ASP.NET AJAX(转帖) VS.net 2008 beta2 新功能 VS 2008 和 .NET 3.5 Beta 2 发布了(转帖) .Net平台开发的技术规范与实践精华总结(转载收藏) 35 岁前程序员要规划好的四件事(转载) ASP.NET程序中常用的三十三种代码(转载) 40种网站设计常用技巧(转载) Visual C#常用函数和方法集汇总(收藏) 访问母版页上的成员 用缓存吧,反正现在内存白菜价,不用白不用。
在MasterPage中使用javascript获取对象
IMustDo · 2006-12-07 · via 博客园 - IMustDo

   MasterPage是VS.net 2005里面的新东西,好象还有很多人都没有用到过,具体使用方法天轰穿的教程里面讲解得比较详细,我就不罗嗦了。

   我在使用的时候遇到过一个问题,就是在使用了MasterPage的内容页中使用javascript获取内容页中的服务器控件时,获取不到对象。
   
   当时我的代码是这样的,举个例子:
   javascript部分:

function a()
{
var txt1
=document.getElementById("txt1");
}

                                   

   页面部分只有一个textbox,ID=txt1;
 
             用上面的代码是会出错的,调试信息是javascript获取不到对象。通过调试,我发现在页面生成之后去查看源代码,会发现内容页中的textbox id会被改成类似这样一个东西 ctl00$ContentPlaceHolder1$txt1

   因此,这里就衍生出其中一种解决方案,我试了一下,把这个 ctl00$ContentPlaceHolder1$txt1去替代javascript中的txt1,程序是可以起作用的。
   但是这样会带来一个问题。ctl00$ContentPlaceHolder1$txt1是程序自动生成的,我们不知道什么时候程序会去改变他,有很大的不可靠性在里面,如果程序把这个id改变了,那么我写的javascript就不起作用了。

   为了这个问题我在CSDN的javascript版上问了好久,都没有人能给我解答。

   幸运的是我找到了另外一种相对可靠的解决方法,共享一下。
   JavaScript部分改成这样

function a()
{
var txt1
=document.getElementById("<%=txtVirusName.ClientID%>");
}

         这样就可以用了。