Sencha EXTJS and MVC pattern - model-view-controller

I am coming up to speed on modifying an application built in EXT,and I would like to use an MVC pattern with the overall architecture. Could someone point out how I can load views dynamically in EXT? For instance, to make a blind call to a controller that will return some kind of view that could be html, a grid, a window, etc...
I'm open to a javascript only solution, or one that calls and retrieves views from asp.net mvc.
thanks

Related

MVC pattern: js code that is calling server via ajax part of view or controller?

I know that the webpage that is opened by the user is part of the view. This one is easy, but what about js code calling the server to retrieve data via ajax? Is this part of the controller or still the view?
Can the view request data like this?
Thank you very much for any help.
Javascript, including Ajax, is a client-side technology. Therefore, in the context of MVC, any js script must be part of a template file.
Note that a template file is not the view (the V in MVC), but a part of it. The view should incorporate both server-side components (classes, interfaces, etc) and client-side components (html, js, css, images, etc). For example, an instance of a view class could read some data from the domain model and then load and render a certain template file, injecting the fetched data into it (formatted), in order to be printed on the screen.
So, an ajax object should be defined in a template file. Its request to the server is handled either by the controller, or by the server-side components of the view, depending on the MVC approach that you are choosing to implement. Though, the server response should always be created by the server-side components of the view.

Is it possible to render body with ajax in asp .net mvc project with layout?

Is it possible to render body with ajax in asp .net mvc project with layout?
Yes, it is possible, but it doesn't make any sense as it will result in a completely broken and invalid markup. You will end up with a 2 headed and 2 body beast like Quazimodo. Actions that are requested view AJAX normally should return only partial views, not full views with layout. Or if you if you belong to some bandwidth saving party you could have your actions return JSON and then use a client side templating framework in order to lay out the markup.
RenderBody is used on page postbacks to render a new HTML document with data from the server that has been annotated with the Razor templating engine. AJAX is used to retrieve data from the server asychronously (in a JSON format typically). An AJAX request can be used to retrieve the same data that RenderBody() would, but it wouldn't make much sense and isn't best practice.

Events in ASP.Net MVC

I read that there aren't events in ASP.Net MVC.
However, I added button and when I double click it a buttonClick event was made.
So, are there events in Asp.Net MVC or not?
That is because you are using the webforms view engine. This view engine includes all the page life cycle stuff from the webforms framework. That means that you can, theoretically, use anything from webforms in asp.net mvc if you are using the webforms view engine. However, I'd strongly suggest that you don't do that. You will miss out on all the advantages with asp.net mvc and you'd be better of just using webforms in the first place.
If you are new to asp.net mvc I'd suggest that you'd use another viewengine instead as that will help you learn the framework a lot better and faster. There is a viewengine from Microsoft called Razor that you could start with.
If you're seeing a buttonClick event handler created when you double-click a button, you are likely attempting to use the Button server control. Instead you should simply include an <input type="submit" value="Button Text" /> element within a <form>. The form's action will result in the controller's action method being called on the subsequent post request.
I highly suggest that you do some do some research on ASP.NET MVC. There are several good resources, but here's a short introductory video to start with:
http://www.asp.net/mvc/videos/mvc-2/how-do-i/5-minute-introduction-to-aspnet-mvc
There are not server control events like there are in webforms. There are jQuery and javascript events that can happen in the HTML/DOM though.
If you double clicked a button on a designer canvas in visual studio, and it created a button click method in another file with a signature like public void MyEvent(EventArgs e), then you are not working with an MVC project.

MyUpdatePanel.Update() in Razor

I am trying to convert my existing ASP.NET application to MVC 3 Razor. I use a lot of updatepanels, and I do conditional updates at the code behind using MyUpdatePanel.Update().
I am not finding this functionality with MVC 3. I can see a lot of blogposts talking about jQuery and how to use it to achieve the same, but I want to render other partialviews from my action conditionally. Is it possible to achieve it?
The way you'd work with Ajax in ASP.NET MVC is completely different from the ASP.NET way (i.e., Ajax toolkit with server-side controls such as UpdatePanel).
ASP.NET MVC is more basic and therefore more work. You handle Ajax calls on the client side using a library such as jQuery, and on the server side you implement a controller with Ajax methods.
Have a look at http://sweettam.blogspot.com/2011/06/aspnet-mvc-3-ajax-part-i.html.

Live Search using ASP.NET MVC and AJAX

I am looking to implement a live search in my MVC app similar to this site when you type in a question and results come up that are similar or like the search on http://www.krop.com/
I have the search code all working and results updated. I just need to know how to add the AJAX to the MVC framework (I know this site was built using it) so that when I type the results are updated.
I had this all working in normal ASP.NET Forms app.
what you need to do it attach to Jquery onchage event handler, and then call some ajax method of jquery ($.load , $.ajax etc...) and the information from a specified controller. asp.net mvc controller can return json results so you can later manipulate it in your javascript code.
if you have any other questions go ahead and ask.
An ASP.NET MVC site will have AJAX and JQuery available by default.
Mike Bosch's Blog can give you some pointers on this

Resources