将 ASP.NET AJAX 转换为 MVC - 什么是“等效”?服务器端事件?

发布于 2024-11-15 18:35:22 字数 506 浏览 0 评论 0原文

我刚开始将 ASP.NET AJAX 编写的页面转换为 MVC。我是 MVC 架构模式的新手,正在尝试了解应该如何处理这两个事件——onloaddocklayout 和onsavedocklayout。它们是之前在我的 aspx.cs 页面中声明的服务器端事件。

有人能给我一个正确方向的碰撞吗?我发现这个线程,但我不认为这正是我正在寻找的?我应该在控制器中写一些代码吗?

<telerik:RadDockLayout ID="RadDockLayout1" Runat="server" onloaddocklayout="RadDockLayout_LoadDockLayout" onsavedocklayout="RadDockLayout_SaveDockLayout">

I am in the very beginnings of converting a page written in ASP.NET AJAX to MVC. I am new to the MVC architectural pattern and am trying to wrap my head around what should be done about these two events -- onloaddocklayout and onsavedocklayout. They were server-side events declared in my aspx.cs page before.

Could someone offer me a bump in the right direction? I found this thread, but I don't think that is quite what I'm looking for? Should I be writing some code down in the Controller?

<telerik:RadDockLayout ID="RadDockLayout1" Runat="server" onloaddocklayout="RadDockLayout_LoadDockLayout" onsavedocklayout="RadDockLayout_SaveDockLayout">

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

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

发布评论

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

评论(3

风筝在阴天搁浅。 2024-11-22 18:35:22

我不知道您是否尝试在 MVC 3 页面内使用 Telerik 控件,但这不是您应该遵循的路径。您可以在 MVC 中使用一些 ASP.NET 控件,但仅限那些不依赖 ViewState 或页面回发的控件

在 MVC 中,控制器和操作作为服务器端代码。所以这是你能做到的唯一方法,但我不认为你可以使用你的 Telerik 控件。

不过,您可以查看 Telerik 网站,他们有一些针对 ASP.NET MVC 的良好控件

I don't know if you're trying to use your Telerik control inside MVC 3 page but it's not the path you should follow. There is some ASP.NET controls you could use in MVC but only ones that doesn't rely on ViewState or page postback.

In MVC you have controllers and actions as a server side code. So it's the only way you can do it but I don't think you can use anyway your telerik control.

However you can check Telerik web site they have some good controls for ASP.NET MVC

友欢 2024-11-22 18:35:22

作为一名 Webforms 人员,我也在尝试理解 MVC 及其哲学,我应该说它与 Webforms 完全不同。 Asp.net Webforms 封装了大部分内容,它具有视图状态,并且可以提供基于事件的机制,如 Windows 窗体应用程序。但这并不是 http 的实际工作方式。所以 MVC 有点回归基础,它没有按钮点击等。

视图只是普通的 html 控件(哦,是的,使用 HTMLHelper 扩展它会变得更容易)。你的控制器(在这种情况下,是的,你应该编写一个控制器)就像视图和存储库之间的桥梁。

控制器示例:

假设您有一个像这样的控制器,

public class MyController : Controller
{

   public ActionResult Action()
   {
   return View();
   }

   [HttpPost]
   public ActionResult Action(MyModel m)
   {
   //
   }
}

在这种情况下,第一个 Action 方法类似于 Page_Load,而不是回发,另一个用 HttpPost 装饰的方法类似于带有 posback 的 Page_load。

您可能有点困惑我如何处理多个按钮:如何在 ASP.NET MVC Framework 中处理多个提交按钮?

相关主题:

https://stackoverflow.com/questions/46031/why-does- the-asp-net-web-forms-model-suck

我旁边有人没有获得 ASP.NET MVC 吗?

As a webforms guy, I am also trying understand MVC and its philosphy, and i should say its quite different then webforms. Asp.net webforms encapsulate most of the things under the hood that way it has viewstate and can provide event based mechanism like windows form application. But its not the actual way of how http works. So MVC is kind of back to basics and it doesnt have button clicks etc.

Views just normal html controls( oh yes with HTMLHelper extensions it gets easier) . Your controller ( in this case yes you should write a controller) is like a bridge between view and your repositories.

Controller Example:

lets say you have a controller like this

public class MyController : Controller
{

   public ActionResult Action()
   {
   return View();
   }

   [HttpPost]
   public ActionResult Action(MyModel m)
   {
   //
   }
}

in this case first Action method is like Page_Load not postback, and the other one decorated with HttpPost acts like Page_load with posback.

You might have a little bit confused how can i handle multiple buttons: How do you handle multiple submit buttons in ASP.NET MVC Framework?

Related topics :

https://stackoverflow.com/questions/46031/why-does-the-asp-net-web-forms-model-suck

Does anyone beside me just NOT get ASP.NET MVC?

娜些时光,永不杰束 2024-11-22 18:35:22

ASP.NET WebForms 中的服务器端事件在 ASP.NET MVC 中没有等效的映射。这是一个完全不同的范例。

Telerik 确实提供 MVC 产品线。如果您正在寻找对接框架,我确信那里有一些东西。

Telerik 的 Docking 控件只是 javascript 和 html。您可以反思它并发现它是如何工作的并编写您自己的!

使用 jQuery 进行高级对接

Server-side events in ASP.NET WebForms don't have an equivalent mapping in ASP.NET MVC. It's an entirely different paradigm.

Telerik does offer an MVC product line. If you are looking for a docking framework I'm sure there is something out there.

Telerik's Docking control is just javascript and html. You could reflect into it and discover how it works and write your own!

Advanced docking using jQuery

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