jQuery will be/is distributed with VisualStudio/ASP.NET MVC,虽然我不称之为框架的一部分。我认为你可以随意使用它并相信它会得到支持。
请注意,微软已经表示,他们将使用jQuery开发的主线,因此代码本身不会与从jQuery.com下载的内容不同,除了内置的Intellisense。
编辑:要设置您的功能,请从jquery.com下载代码。把它放在你的脚本文件夹中,或者存储javascript内容的地方。为它添加一个脚本引用到你的页面。使用jquery将onchange处理程序添加到下拉列表中,并且当下拉列表的值是其他时显示文本框,否则将其隐藏。以下示例假定other
不是默认选择。如果您正在使用MasterPages或UserControls内部的runat =“server”控件,则需要在javascript函数中调整名称以解释ASP.NET所做的名称。为他们提供独特的CSS类并使用“.class”表示法而不是“#id”表示法引用它们可能更简单。
<script type="text/javascript" src="...pathtoscript../jquery.1.2.6.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#DropDownListID").bind('change', function() {
if (this.options[this.selectedIndex].value == 'other')
{
$("#TextBoxID").show();
}
else
{
$("#TextBoxID").hide();
}
});
});
</script>
...
<select id="DropDownList">
<option value='first'>First</option>
...
<option value='other'>Other</option>
</select>
<input type='text' id='TextBox' style='display: none;' />
需要什么,以获得jQuery的功能做?在这一点上,我不在乎intellisense。 – dtrick 2008-12-31 02:36:13