简体   繁体   English

如何在asp.net Web应用程序的代码背后使用jquery

[英]how to use jquery in the codebehind of asp.net web application

Q:many times , i find my self need some features ,and when search and search i find all i need as jquery files , i donot know jquery , all i know that it is javascript library ,now i wanna to know if i have set of jquery files , after including those files in any asp.net application . 问:很多时候,我发现自己需要一些功能,当进行搜索时,我找到了所有需要的jquery文件,我不知道jquery,我只知道这是javascript库,现在我想知道是否已设置将jquery文件包含在任何asp.net应用程序中之后。 how to use them ,i mean how to use their functions in the .cs(code behind) file..if there is an example to understand the main idea, it will be great. 如何使用它们,我的意思是如何在.cs(后面的代码)文件中使用它们的功能。.如果有一个示例可以理解主要思想,那将是很好的。

thanks in advance 提前致谢

JQuery is for HTML Manipulation (and animation, event handling and Ajax) on the client so you won't be able to use it in your code behind but only on the client ! JQuery在客户端上用于HTML操作(以及动画,事件处理和Ajax),因此您将无法在背后的代码中使用它,而只能在客户端上使用它!

Now using JQuery is simply adding a reference to it in your html like 现在,使用JQuery只是在html中添加对它的引用,例如

<script src="path to jquery.js" type="text/jajascript"></script>

then the js file will be loaded on the client and you will be able to use the JQuery object often used with its alias $. 那么js文件将被加载到客户端上,您将能够使用别名通常为$的JQuery对象。

Follow this tutorial and you should be on track in 18 minutes 遵循本教程 ,您将在18分钟内步入正轨

For your popup problem, you can find a lot of popup plugins here : http://plugins.jquery.com/ 对于您的弹出问题,您可以在此处找到很多弹出插件: http : //plugins.jquery.com/

jQuery网站上有一些很棒的教程

Jquery can be a very useful extra functionality for your application, it will work clientside as you must have realized from your finding that it is a JavaScript library. jQuery对于您的应用程序来说可能是非常有用的额外功能,它将在客户端运行,因为您必须从发现它是JavaScript库的过程中就已经意识到。

I often integrate it with .net applications and that works great. 我经常将它与.net应用程序集成在一起,并且效果很好。 I generally just add it in the aspx-file, not in code-behind, but that should be possible too, if needed, by using the ScriptManager.RegisterClientScriptBlock-functionality. 我通常只是将其添加到aspx文件中,而不是在代码隐藏中,但是如果需要的话,也可以使用ScriptManager.RegisterClientScriptBlock功能来添加它。

JQuery is very well documented. JQuery有很好的文档记录。 Take a look at http://docs.jquery.com/Tutorials When you get the basics, you will soon get the point how and if you can use it for your features. 看看http://docs.jquery.com/Tutorials。当您掌握了基础知识之后,很快就会知道如何以及是否可以将其用于功能。

The example you link to shows somebody using the ScriptManager class to output script to the client, where it runs. 链接到的示例显示了有人使用ScriptManager类将脚本输出到运行脚本的客户端。

This is a tool that ASP.net provides to simplify outputting dynamic <script> tags - it does not run the javascript on the server at all. 这是ASP.net提供的用于简化动态<script>标记输出的工具-它根本不会在服务器上运行javascript。

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

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