ASP.NET 转换为完全基于 AJAX 的应用程序

发布于 2024-10-10 13:12:20 字数 426 浏览 0 评论 0原文

我负责将 ASP.NET Web 应用程序转换为完全基于 AJAX 的应用程序。我非常了解 Javascript 和 Jquery。

最初我想将每个锚标记的点击事件指向 JS 函数,并通过 ajax 调用内容并填充正文等等。当涉及到每个页面上的 ASP.NET Form 以及需要进行回发时,我遇到了一个问题。我决定将每个 Form 标签的 onSubmit 事件指向 JS 函数,以使用 ajax 发布内容并获取结果,我知道这对于 ASP.NET 来说是不可能的,因为每次单击按钮时,都会回发,因此很难让页面知道单击了哪个按钮。

然后,我决定使用 ASP.NET 内置 AJAX 控件与 Forms 一起使用,这非常简单,并且按照应有的方式工作。

现在我陷入了一个问题:我应该选择哪一个?

我喜欢使用 JS 方式,因为它比 AJAX.NET 更可定制。我非常需要你的建议。

I am in charge of converting an ASP.NET web application into fully AJAX based application. I know Javascript and Jquery very well.

Initially I thought to point every anchor tag's click event to JS function and to call stuff via ajax and to populate the body and so on. I encountered a problem when it came to ASP.NET Form on every page and when there was need to make a post-back. I decided to point every Form tag's onSubmit event to a JS function to post stuff using ajax and to get results and I got to know this is not possible with ASP.NET as every time where is a button click, there will be post back so it's hard to let page know what button was clicked.

I then decided to use ASP.NET built-in AJAX controls to use with Forms which is pretty easy and worked like the way they should.

Now I am stuck with the question of which I should go with?

I like to be JS way because it's more customizable than AJAX.NET. I highly need your suggestions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

几度春秋 2024-10-17 13:12:20

我没有发现使用 ASP.NET Ajax 存在问题。 scriptmanager 和 UpdatePanel 控件将使您轻松快速地转换到支持 ajax 的网站。
我不确定您正在寻找哪种定制,但您仍然可以在必要时使用 js 方式。 ASP.NET Ajax 的另一个优点是它经过了数千个站点的充分测试和使用,并且附带了许多控件,例如 ajaxcontrol 工具包中的控件。

I don't see a problem in using ASP.NET Ajax. The scriptmanager and UpdatePanel controls will make you task easy and fast to convert to and ajax enabled website.
I am not sure what kind of customization you are looking for but you can still use js way whereever necessary. One another plus point with ASP.NET Ajax is it is well tested and used by thousands of sites and comes with lots of controls like in ajaxcontrol toolkit.

[浮城] 2024-10-17 13:12:20

如果您想将 Web 表单应用程序完全转换为 JavaScript 编码,这将非常困难。使用 updatepanel 控件使其看起来对用户来说是异步的会容易得多,因为这不会破坏服务器端集成。但如果你使用 JS 回发到服务器,然后每次都擦除 UI 并用新的替换它,那就会困难很多。

理想情况下,最好的方法是使用 Web 服务,通过 JS 代码(JQuery 或使用 Sys.Net.WebServiceProxy ASP.NET AJAX 对象)调用 Web 服务来传输数据,然后在 JS 中构建客户端。

如果您需要更多信息,请告诉我...

HTH。

If you want to convert a web forms application completely to JavaScript coding, this is going to be really hard to do. It would be a lot easier to use the updatepanel control to make it look asynchronous to the user, as this doesn't break the server-side integration. But if you are using JS to post back to the server, then wipe the UI and replace it with the new one every time, that's going to be a lot harder.

Ideally, the best way is to use web services, call the web services through JS code (either JQuery or using the Sys.Net.WebServiceProxy ASP.NET AJAX object) to stream the data and you build the client in JS.

Let me know if you want more info...

HTH.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文