Sean Anderson
Sean Anderson

Reputation: 29371

Converting ASP.NET AJAX to MVC - What's the 'equivalent' of a server-side event?

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">

Upvotes: 0

Views: 751

Answers (3)

Chuck Conway
Chuck Conway

Reputation: 16435

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

Upvotes: 1

Tomasz Jaskuλa
Tomasz Jaskuλa

Reputation: 16033

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

Upvotes: 1

adt
adt

Reputation: 4360

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?

Upvotes: 1

Related Questions