• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >ASP.NET > ASP.NET开发者使用jQuery应该了解的几件事情

ASP.NET开发者使用jQuery应该了解的几件事情

作者: 字体:[增加 减小] 来源:互联网 时间:2017-05-11

通过本文主要向大家介绍了jquery asp.net,jquery ajax asp.net,用asp.net开发网站,微信开发 asp.net,vs2013 开发asp.net等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

下面这几点希望能够帮你加快你的学习。

1.把selectors当作asp.net中的sets。

   在asp.net的世界,通过一个查询找到一系列控件是非常少见的.相反我们比较习惯于通过一个唯一的ID来找到一个控件。当然,在jQuery中这个也是没有问题的,但是jQuery的选择功能相对更加神奇。

   使用jQuery的selectors能够很容易定位到一个set的元素,相对来说比在asp.net中使用迭代的规则来找到一个set的元素更加清晰和易于表达。

2.使用CSS类来代替styling。

   另外一个不直观的技术是把CSS类作为一个flag。与'selector engin'一样,'flag'类也是个令人惊喜的东西。

   举个例子来说吧,最近有个活动是做一个在线的能够与客户端互动的纸牌游戏。一个需求是纸牌需要有个onclick haddler在某个特定时间,不过这些事件只针对那些face down(脸朝下)的。作为一个.net的开发者我立刻能够想到的办法是让这些纸牌在客户端通过一个collection来编号.然后我可以在需要的时候给这个数据一个onclick handlers。这个固然可以,不过难以维护且有点凌乱。

  现在如果我使用CSS类来实现,face up的纸牌我通过addclass方法为它们加上一个'flipped'类,然后可以通过一个简单的 '$(".card:not(.flipped)")'选择那些face down的纸牌。使用jQuery的click(fn)功能能够让我使用几行代码就实现这个功能。更重要的是它更容易理解和读取。

下面附上几点英文原版的:

3。Understand unobtrusive JavaScript. 
 In the ASP.NET world, we use a lot of what's sometimes termed obtrusive JavaScript.  This means that client-side event handlers are defined as attributes on elements.  For example, several ASP.NET WebControls render an OnClick=”javascript:__doPostBack()”attribute as part of their markup.  This is considered obtrusive JavaScript.

When ASP.NET was initially being developed, this inline JavaScript was the norm.  However, as browsers began providing more sophisticated faculties for imperatively adding event handlers, this declarative technique quickly lost favor with client-side developers. As a consequence, the preferred approach has shifted toward what's called unobtrusive JavaScript.

Unobtrusive JavaScript is now considered a best practice when wiring up client-side event handlers.  This is primarily because it facilitates separation of concerns between behavioral JavaScript and structural HTML markup.  Unobtrusive JavaScript also helps you to write cleaner, more semantic markup, which improves accessibility and often has SEO benefits.

  • Use the console to learn interactively.
    Coming from the save-compile-reload paradigm of statically typed server-side development, it's natural to approach client-side development in a similar fashion.  While you certainly can write client-side code that way, it's akin to working blindfolded when you consider the alternatives.

    Since JavaScript is usually interpreted by a browser, the browser is one of the best debugging environments available.  In particular, a JavaScript “console” is terrific for interactively interrogating the DOM, testing jQuery selectors against actual markup, and refining JavaScript code in real-time.

    My preferred browser-based tool is the
    Firebug addon to Firefox.  I cannot praise this Firebug highly enough.  It has revolutionized how I approach client-side development, both of JavaScript and of CSS.  If you prefer Internet Explorer, IE8's updated developer tools are also very capable in this department.
    Whatever your browser of choice, I urge you to give these utilities a try when debugging client-side functionality.  Once you become proficient with one of these tools, you'll be amazed that you ever developed client-side code without it.
  • Get the VSDOC.
    Even though browser-based tools are great for debugging, an ASP.NET developer's primary editor is still going to be Visual Studio.  When writing jQuery code in Visual Studio, having proper Intellisense can make a tremendous difference in productivity.  The discoverability that Intellisense provides is especially beneficial when you're unfamiliar with jQuery's API.

    As part of the official support for jQuery, Microsoft provides a documentation file to provide jQuery Intellisense inside Visual Studio 2008.  This is provided through what's called a vsdoc file, and is available on the
    jQuery download page (via the “Documentation: Visual Studio” links).
    Jeff King has assembled an excellent FAQ to help you get Visual Studio 2008's JavaScript Intellisense working: 
    http://blogs.msdn.com/webdevtools/archive/2008/11/18/jscript-intellisense-faq.aspx
  • </div>
    分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

    您可能想查找下面的文章:

    • .net jquery绘制自定义表单源码分享
    • .net jquery绘制自定义表单源码分享
    • ASP.NET配合jQuery解决跨域调用的问题
    • ASP.NET中JQuery+AJAX调用后台
    • asp.net中js+jquery添加下拉框值和后台获取示例
    • asp.net中利用Jquery+Ajax+Json实现无刷新分页的实例代码
    • asp.net使用jquery模板引擎jtemplates呈现表格
    • asp.net使用jquery实现搜索框默认提示功能
    • asp.net使用jQuery获取RadioButtonList成员选中内容和值示例
    • asp.net使用jQuery Uploadify上传附件示例

    相关文章

    • 2018-08-20如何为asp.net core添加protobuf支持详解
    • 2018-08-20ASP.NET Core 2.1 使用Docker运行的方法步骤
    • 2018-08-20VS2012实现简单登录界面
    • 2017-05-11asp.net 错误:0x8007000B 异常的解决方法
    • 2017-05-11asp.net下实现输入数字的冒泡排序
    • 2017-05-11.net清空所有Cache的实现代码
    • 2017-05-11GridView多层嵌套和折叠与展开(修改适合自己使用)
    • 2018-08-20asp.net使用H5新特性实现异步上传的示例
    • 2017-05-11asp.net生成缩略图实现代码
    • 2017-05-11.NET示波器控件的实例代码分析

    文章分类

    • JavaScript
    • ASP.NET
    • PHP
    • 正则表达式
    • AJAX
    • JSP
    • ASP
    • Flex
    • XML
    • 编程技巧
    • Android
    • swift
    • C#教程
    • vb
    • vb.net
    • C语言
    • Java
    • Delphi
    • 易语言
    • vc/mfc
    • 嵌入式开发
    • 游戏开发
    • ios
    • 编程问答
    • 汇编语言
    • 微信小程序
    • 数据结构
    • OpenGL
    • 架构设计
    • qt
    • 微信公众号

    最近更新的内容

      • Asp.Net Core轻量级Aop解决方案:AspectCore
      • C#中的委托和事件学习(续)
      • 解决asp.net上传文件超过了最大请求长度的问题
      • asp.net button 绑定多个参数
      • Asp.net中Request.Url的各个属性对应的意义介绍
      • asp.net后台动态添加JS文件和css文件的引用实现方法
      • asp.net mvc中Forms身份验证身份验证流程
      • 注册页实现激活邮箱验证(asp.net c#)
      • asp.net GridView控件中模板列CheckBox全选、反选、取消
      • .NET发送邮件的实现方法示例

    关于我们 - 联系我们 - 免责声明 - 网站地图

    ©2020-2025 All Rights Reserved. linkedu.com 版权所有