简体   繁体   English

我需要使用 C# 和 ASP.Net 构建一个重量非常轻的 Ajax 引擎。 你有什么建议?

[英]I need to build a very light weight Ajax Engine using C# and ASP.Net. What do you suggest?

I have before created a quick Ajax Framework for one of my projects.我之前为我的一个项目创建了一个快速的 Ajax 框架。 It was an ASP.Net Website (C#).这是一个 ASP.Net 网站 (C#)。 There was not a lot of Ajax type functions so I just made a new Page with nothing in it and in the code behind file I put some code in the Page_Load method which would look for an action in the request and then call the appropriate method.没有很多 Ajax 类型的函数,所以我只是创建了一个新页面,其中没有任何内容,并且在文件后面的代码中,我在 Page_Load 方法中放置了一些代码,该方法将在请求中查找操作,然后调用适当的方法。

I am in the same scenario again and I am finding that I am tempted to do the same again.我再次处于相同的场景中,我发现我很想再次做同样的事情。 I am letting the user create a new accommodation.我让用户创建一个新的住宿。 Two of the fields that belong with accommodation are accommodation type and area.属于住宿的两个字段是住宿类型和面积。 Both of these fields are maintained by the users so they can CRUD both of these fields on other pages.这两个字段都由用户维护,因此他们可以在其他页面上对这两个字段进行 CRUD。 I was thinking that if the area or accommodation type did not yet exist it would be irritating to have to go to another page.我在想,如果该区域或住宿类型尚不存在,则必须将 go 转到另一个页面会很烦人。 So instead I want to give them the functionality of adding new areas and adding new accommodation types on the same form.因此,我想给他们添加新区域和在同一表格中添加新住宿类型的功能。 So I have tickboxes for the accommodation type, when they click new I present them a textbox they enter the value and click add.所以我有住宿类型的复选框,当他们单击新建时,我向他们显示一个文本框,他们输入值并单击添加。 It makes an Ajax call to the database to add the value and then a new tickbox appears if successful else an error message.它对数据库进行 Ajax 调用以添加值,然后如果成功,则会出现一个新的复选框,否则会出现错误消息。 Very similar for area except I will be using a drop down list.除了我将使用下拉列表外,区域非常相似。

This time however I am using some jQuery too.不过这次我也使用了一些 jQuery。 I am not that familiar with jQuery's Ajax libraries YET.我对 jQuery 的 Ajax 库还不太熟悉。 My question is, "Is there a...我的问题是,“有没有...

  1. Better更好的
  2. Easier更轻松
  3. Smarter更聪明
  4. More Extendable更可扩展
  5. All of the above上述所有的

way of doing this." If so can you please point me in the right direction.这样做的方法。”如果可以,请您指出正确的方向。

Given that with VS2008 there's support for AJAX already built into the IDE (and with jQuery support coming), I think you'll find it tough to come up with something which is not only a better user experience but also a better developer experience.鉴于 VS2008 支持 AJAX 已经内置到 IDE 中(以及 jQuery 支持即将到来),我认为你会发现它只是一个更好的用户体验,但也不是更好的开发者体验。

The Visual Studio team not only have a lot of resources invested in making this work well, but they also know how to integrate features into the IDE, almost certainly better than you do (and with more access to do so, I suspect). Visual Studio 团队不仅投入了大量资源来使这项工作顺利进行,而且他们还知道如何将功能集成到 IDE 中,几乎可以肯定比您做得更好(而且我怀疑有更多的访问权限)。

If you want to do this for fun (or as part of MonoDevelop, for instance), that makes sense - but from a productivity point of view, I'd just stick to Visual Studio.如果您想这样做是为了好玩(或作为 MonoDevelop 的一部分,例如),这是有道理的 - 但从生产力的角度来看,我会坚持使用 Visual Studio。

I dont think you need to create an entirely new Ajax Framework.我认为您不需要创建一个全新的 Ajax 框架。 A lot of time and effort by many people has been put into other frameworks like the Asp.net Ajax, jQuery, and others.许多人已经将大量时间和精力投入到其他框架中,例如 Asp.net Ajax、jQuery 等。 Take some time to learn what these frameworks provide for you and how you can use them.花一些时间来了解这些框架为您提供了什么以及如何使用它们。 If you still find them lacking nearly all of them have ways to extend on their already built features.如果您仍然发现它们缺乏,几乎所有这些都可以扩展其已构建的功能。

I'm not going repeat what Jon Skeet said and I am sure twenty other people are typing;我不会重复 Jon Skeet 所说的话,我相信还有 20 个人正在打字。 however, if you decide to roll your own, instead of using a blank ASPX page, look into creating your own Http Handler .但是,如果您决定自己动手,而不是使用空白的 ASPX 页面,请考虑创建自己的Http 处理程序 In visual studo you can create you own quick and dirty handler.在视觉工作室中,您可以创建自己的快速而肮脏的处理程序。 They have an extension of.ASHX.它们的扩展名为 .ASHX。 The benefit here is you avoid the overhead of the page object framework.这里的好处是您避免了页面 object 框架的开销。

jQuery is in my experience a very good library with a lot of community support. jQuery 以我的经验是一个非常好的库,有很多社区支持。 Check out the jQuery IRC channel if you can't find what you are looking for in the documentation.如果您在文档中找不到所需的内容,请查看 jQuery IRC 频道。 We have an Ajax intensive application and it runs on jQuery as its core framework.我们有一个 Ajax 密集型应用程序,它以 jQuery 作为其核心框架运行。 We have been pleased with the results.我们对结果感到满意。 If you are worried about size, Google hosts jQuery so your clients can cache it locally.如果您担心大小,Google 会托管 jQuery,以便您的客户可以在本地缓存它。

Alternatively, you may just want to create the proper HttpHandler(s) that will allow your client code to call server side resources without the overhead of a traditional ASP.NET Page class.或者,您可能只想创建正确的 HttpHandler(s),以允许您的客户端代码调用服务器端资源,而无需传统 ASP.NET 页面 class 的开销。

Check out this article from MSDN从 MSDN 查看这篇文章

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

相关问题 如何像在ASP.Net中一样将sqlconnecton设置为datadirectory。 我正在使用C#表格 - How to set sqlconnecton to datadirectory like in ASP.Net. i'm using C# form C#和ASP.Net。 需要指导 - C# and ASP.Net. Guidance required 我需要做些什么才能使用C#ASP .NET Web API发送Protobuf序列化数据? - What do I need to do to send out Protobuf serialized Data using C# ASP .NET web api? 没有使用c#asp.net从数据库获取任何行数据。 - Not getting any row data from database using c# asp.net. 在使用c#asp.net绑定到Repeater之前,更改图像大小。 - Change the Image size before bind inside Repeater using c# asp.net. ASP.NET。 MVC 2 C#:太多空白 - ASP.NET. MVC 2 C#: So much whitespace 如何构建C#asp.net ajax向导(或转换为基于PlaceHolder的向导) - How do I build C# asp.net ajax wizard (or rather convert a PlaceHolder based wizard) 在Visual Studio 2013上发布用c#asp.net创建的网站,我需要做什么? - What do I need to do to publish a website made in c# asp.net on Visual Studio 2013? 我如何使用asp.net打印HTML表。 每页的页眉和页脚 - how do i print HTML table using asp.net. Header and footer on each page 使用c#ansd asp.net在Asp.Net页面上显示sql server的多行值。 - Display multiple rows value of sql server on Asp.Net page using c# ansd asp.net.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM