本文介绍了有没有一种方法可以防止ASP.Net破坏控件ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个控件:
I have a control:
<asp:TextBox ID="ControlName" runat="server" />我想在一些Javascript中引用它. ASP.Net将ID修改为ctl00_ContentPlaceHolder1_ControlName. 为了简单起见,我想在脚本中将其称为ControlName:页面的未来版本可能会将控件放在不同的容器中,这会更改ID,并且我宁愿不必记住重写脚本.
I want to reference it in some Javascript. ASP.Net mangles the ID into ctl00_ContentPlaceHolder1_ControlName. To keep things simple I want to refer to it as ControlName in my script: future versions of the page might have the control in a different container which would alter the ID, and I would rather not have to remember to rewrite the script. Is there any way to instruct ASP.Net, either for this specific control or generally, NOT to mangle the ID?
推荐答案这是什么?之所以发生这种情况,是因为您使用的是母版页.检查以下内容: http: //weblogs.asp/scottgu/archive/2006/04/18/Great-New-Advanced-Article-on-ASP.NET-2.0-Master-Pages.aspx [ ^ ] It''s happening because you''re using a master page. Check this: weblogs.asp/scottgu/archive/2006/04/18/Great-New-Advanced-Article-on-ASP.NET-2.0-Master-Pages.aspx[^]
更多推荐
有没有一种方法可以防止ASP.Net破坏控件ID?
发布评论