有没有一种方法可以防止ASP.Net破坏控件ID?

编程入门 行业动态 更新时间:2024-10-12 08:27:17
本文介绍了有没有一种方法可以防止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?

本文发布于:2023-11-17 09:00:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609547.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   可以防止   方法   ASP   Net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!