简体   繁体   English

SL中的x:Name =“ someName”与Asp.Net中的ID =“ someID”有什么区别?

[英]What is the difference between x:Name=“someName” in SL and ID=“someID” in Asp.Net?

I have an Asp.Net background and trying to learn Silverlight. 我有一个Asp.Net背景,正在尝试学习Silverlight。

Can you explain, what is the difference between x:Name="someName" in Silverlight, XAML and ID="someID" in Asp.Net markup? 您能否解释一下,Silverlight中的x:Name =“ someName”,XAML和Asp.Net标记中的ID =“ someID”有什么区别?

(If they both make a element unique, why one is called Name and the other is called ID ? ) (如果它们都使元素唯一,为什么一个叫Name,另一个叫ID?)

I gather compatibility with ASP.Net was not one of the requirements considered when they designed Silverlight (which derived in turn from WPF) :) 我收集到与ASP.Net的兼容性并不是他们设计Silverlight(从WPF继承而来)时考虑的要求之一:)

"ID" is a very technical term whereas "Name" is a bit more human readable. “ ID”是一个非常技术性的术语,而“ Name”则更易于理解。 They are after all just the matching name of a member of the code-behind class generated at compile time. 它们毕竟只是编译时生成的代码隐藏类成员的匹配名称 ID as a term makes more sense for data keys etc. ID是术语,对于数据密钥等而言更有意义。

Classic ASP, and then ASP.Net, date back to before WPF and way before Silverlight so the naming is going to be a bit more old-school. 经典ASP,然后是ASP.Net,可以追溯到WPF之前,也可以追溯到Silverlight之前,因此命名将有些陈旧。 Being more recent the naming of most elements tends to be a bit more sensible in Silverlight (compared to ASP). 最近,大多数元素的命名在Silverlight中(与ASP相比)往往更加明智。

Note: This is all just my opinion based on working with all the above technologies for many years. 注意: 这只是我多年使用以上所有技术的观点。 Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM