Quickest way to add a DataGrid to an MVC.NET app: ASP.NET AJAX or jQuery? - asp.net-mvc

I have an ASP.NET MVC application which uses plain HTML. I quickly need to add tabs and a datagrid to it. I've been evaluating ASP.NET AJAX and jQuery, but am running out of time to make a decision.
If I needed to add these 2 features quickly, how should I proceed? ASP.NET AJAX or jQuery?

If you are adding a grid to MVC, your best bet is JQuery. The ASP.NET DataGrid is not going to work with MVC, because MVC doesn't support postbacks. The ASP.NET AJAX tabs may not work either.
Here is a plugin for the tabs:
http://stilbuero.de/jquery/tabs_3/
And here is a plugin for the Grid:
http://www.trirand.com/blog/
If you want to roll-your-own server-side GridView control for MVC, see here:
http://stephenwalther.com/blog/archive/2008/06/25/asp-net-mvc-tip-9-create-a-gridview-view-user-control.aspx
There is also a Grid Component in MVCContrib:
http://mvccontrib.codeplex.com/Wiki/View.aspx?title=Grid&referringTitle=Home
jQuery UI Extensions for ASP.NET MVC contains tabs:
http://jmvcui.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=33636

Related

if asp.net mvc doesnot support page load event then what should we do for page laod event in mvc

I am new to ASP.NET MVC .
To start learning on MVC, I was going through a tutorial on MVC, where they used the Page_Load event which is same as in Web forms.
Does MVC support events, and if so what events are supported?
If ASP.NET MVC does not support Page_Load event, then what is the alternative?
One thing that i was told before learning MVC was, 'Just forget everything about Webforms. It's old, and doesn't support separation actually.' Don't think about asp.Net webforms while learning MVC. MVC has a different life cycle.
An answer to your question is, MVC doesn't support Page_Load or any event, and it all depends on what you want to implement. Here are few tips:
1.) If you want to implement something before View (UI or html page) is rendered, you can write logic in controller before returning the View.
2.) If you want to implement something in the process of rendering page, you can use razor markups. It is quite easy to use razor.
3.) If you want to implement something after Page has been totally rendered, you can use jQuery's document.Ready().
You can start learning MVC here: http://asp.net/mvc
You should use Javascript/Jquery for event handling in MVC application. You may be use document.Ready() event handler to trigger the page load event and then handle your logic using javascript/jquery.

Implement Asp.Net Ajax Controls in MVC

I was reading telerik post
About Telerik ASP.NET AJAX Controls in MVC project. According to them we can implement Telerik AJAX control in Asp.Net MVC. So my question is can we implement ASP.Net Ajax control in my Asp.Net MVC Project.
If Yes how could it should be done?
Yes you can, but you must be aware of the limitations. You can read more from their documentation on Telerik.com; they have some documentation on this process. I would recommend using the MVC helpers where possible.

How to access Page.Header.Controls in ASP.NET MVC 2?

Is there a way to access Page.Header.Controls in ASP.NET MVC 2?
Edit
I want to create a helper which can manage scripts.
Yesterday, after I asked this question I discovered, that ViewPage and ViewUserControl has Page property.
I think this allows us to access Page.Header.Controls.
No, Page.Header doesn't exist in ASP.NET MVC. Header is the <head runat="server> control in ASP.NET Web Forms. ASP.NET MVC doesn't use controls like that.
If you want logic in the <head> of your HTML, you have to go about it the ASP.NET MVC way, by using code in your view or your master page.
The Page property of a ViewPage comes from the fact that Web Form Views are bastard Web Forms. ASP.NET MVC normally doesn't use any bits of the Web Forms beside the code-in-front and the markup, but via various unsupported haacks you can abuse it into letting you use other Web Forms stuff. Don't do it.

AJAX Toolkit for ASp.net MVC

Is there any ajax toolkit for asp.net MVC
As MVC does not have ViewState or the Web Forms postback model the AjaxControlToolkit will not work with it.
There is a project to do this (http://mvccontroltoolkit.codeplex.com/) but it's not yet released.
There are numerous blogs where have got different controls working but to be honest I'd suggest looking at jQuery and its plugins (http://www.jqueryui.com/). MVC lends itself far more naturally to these, it is not control-based.
Here's another resource talking about this: http://www.hanselman.com/blog/ASPNETMVCPreview4UsingAjaxAndAjaxForm.aspx
In addition, ASP.NET MVC lends itself quite easily to making your own amazing ajax controls, especially when combined with jQuery.
The emphasis in ASP.NET MVC is more on HTML and client-side code when talking about user-control similar to those in the AJAX Toolkit - you may like to check out the excellent http://www.jqueryui.com/ for some good client-side controls.

mvc gridview with code

how to get a gridview in model view control,how to edit,delete the gridview with source code
Telerik has a great grid that's free (open source) for MVC. You can view it here, and the download is on their web site.
http://demos.telerik.com/aspnet-mvc/grid
You don't have access to ASP.NET controls in ASP.NET MVC, well not with the postback and viewstate stuff atleast.
However, you can create a nice GridView with ajax edit/delete capabilities by using something like jqGrid and a little code. Here are a couple of blog posts to get you started :
Full Walkthrough of MvcContrib Grid with jQuery Data table
Using jQuery Grid With ASP.NET MVC
Hope that helps
Paginated List
Divides IQueryable source of any type on pages and returns items for current page. Useful for creating custom gridviews and pagers in C#, ASP.NET WebForms or MVC. Althought this code is used for pagnition, there is example on how to create Gridview with paging. Shouldn't be too hard to create CRUD actions from it.

Resources