0

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">
Community
  • 1
  • 1
Sean Anderson
  • 27,963
  • 30
  • 126
  • 237
  • MVC is pretty simple: HTML -> JavaScript -> GET/POST Action on Controller -> Response. There's none of that event processing stuff. When you get into asynchronous controllers, it's a little harder to understand. Although, your requests/responses still travel through the HttpModule (MvcApplication). – Joseph Yaduvanshi Jun 17 '11 at 21:29
  • :) I agree that the architecture itself is simple, but wrapping my brain around "I just wrote my first professional website in ASP.NET AJAX and now need to convert it to MVC" is kinda intimidating on Day 1. – Sean Anderson Jun 17 '11 at 21:33

3 Answers3

1

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?

Community
  • 1
  • 1
adt
  • 4,320
  • 5
  • 35
  • 54
1

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

Tomasz Jaskuλa
  • 15,723
  • 5
  • 46
  • 73
  • I am on the Telerik page already and have been reading through their guides. A user stated in a forum thread that he successfully brought over RadDockLayout from AJAX to MVC, but Telerik's stance is that they do not officially support this control. The user did not post his solution, so I'm left tinkering for now. Thank you though :) – Sean Anderson Jun 17 '11 at 21:19
  • What I'm sure about is that if your control needs ViewState or page postabacks you will be in trouble. Maybe it will be easier for you to get rid of that control and to chose another one ? – Tomasz Jaskuλa Jun 17 '11 at 21:24
  • Well, the control is simply acting as a manager. I believe I could write the things it is doing on my own, I just wanted to use it. :) – Sean Anderson Jun 17 '11 at 21:29
1

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

Chuck Conway
  • 16,287
  • 11
  • 58
  • 101
  • Their MVC framework isn't fully fleshed out yet. I was hoping to port my ASP.NET AJAX to MVC and then replace controls as they become released. They do not currently offer a docking framework. – Sean Anderson Jun 17 '11 at 21:28
  • @Sean take a look at this framework: http://www.jankoatwarpspeed.com/post/2009/06/01/Advanced-docking-using-jQuery.aspx – Chuck Conway Jun 17 '11 at 21:42
  • Thanks. I bookmarked it for now, but will try and get to that point soon! – Sean Anderson Jun 17 '11 at 21:43