vb.net : 不是有效的标识符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14704114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
: is not a valid identifier
提问by w0051977
A colon cannot be used in the ID of a .NET control. I quote from the following website: http://msdn.microsoft.com/en-us/library/system.web.ui.control.id.aspx
.NET 控件的 ID 中不能使用冒号。我引自以下网站:http: //msdn.microsoft.com/en-us/library/system.web.ui.control.id.aspx
"Only combinations of alphanumeric characters and the underscore character ( _ ) are valid values for this property. Including spaces or other invalid characters will cause an ASP.NET page parser error."
“只有字母数字字符和下划线字符 (_) 的组合才是此属性的有效值。包含空格或其他无效字符将导致 ASP.NET 页面解析器错误。”
Is there a reason why alphanumeric characters have to be used?
是否有理由必须使用字母数字字符?
回答by freefaller
Easy to find on MSN...
在MSN上很容易找到...
Only combinations of alphanumeric characters and the underscore character ( _ ) are valid values for this property. Including spaces or other invalid characters will cause an ASP.NET page parser error.
只有字母数字字符和下划线字符 (_) 的组合才是此属性的有效值。包含空格或其他无效字符将导致 ASP.NET 页面解析器错误。
As for why, I cannot give an answer, other than it makes sense to me as a developer that you never use anything other than alphanumerics and underscores for variable names. There's no obvious reason why that should not extend to control IDs as well.
至于为什么,我无法给出答案,除了对我作为开发人员来说,除了字母数字和下划线之外,您永远不会使用任何变量名作为变量名是有意义的。没有明显的理由不应该扩展到控件 ID。

