This article explains how to create and consume a User Control in MVC. I hope you will like it.
Please see this article in my blog.
Background
Today I got the requirement to work with CellSetGrid. Since it is supported with our normal ASP.Net web pages alone, I was in a need to convert it to a user view control and consume it in MVC because my application is in MVC4. I have done it. So I thought of sharing it with you all.
Using the code
To do so, you need to use the following procedure.
Add a reference to your control DLL.


Add a new Web User Control.


Register your DLL reference.
- <%@ Register assembly="CellSetGrid2" namespace="OLAPControls" tagprefix="cc1" %>
Place your control.
- <div>
- <cc1:CellSetGrid2 id="csg2" runat="server" connectionstring="Data Source="Your DataSource"; Initial Catalog =Your DB Name"
- cube="Your Cube Name" height="800px" width="1500px" />
- </div>
Go to ADODMGrid.ascx.cs from the Solution Explorer.

Change the namespace System.Web.UI.UserControl to System.Web.Mvc.ViewUserControl.
Create the Controller.

Create a View.

Please ensure that you have selected a partial view.

Add the User Control to your View as in the following:
- @Html.Partial("ADODMGrid")
- @* Here ADODMGrid is our user control name. No need to give its extension (ascx)*@
So here we are add our new web user control to our view.
Add tagPrefix to your Web.Config
Last but the least, you need to add tagPrefix to your web.config file as follows.
- <controls>
- <add tagPrefix="cc1" namespace="OLAPControls" assembly="CellSetGrid2, Culture=neutral, PublicKeyToken=null" />
- </controls>
Now when look at your view, you can see your control there.
Conclusion
That is all. I hope you liked this article. Please share me your feedback.
Kindest Regards,
Sibeesh Venu


Sibeesh VenuTOP 100Posted Jul 17, 2015, 1:57 AM EDT
Gopi Chand Thank you
Gopi ChandPosted Jul 17, 2015, 1:40 AM EDT
Nice one Sibeesh
Sibeesh VenuTOP 100Posted Jul 16, 2015, 11:50 PM EDT
Sharad Thank you
Sibeesh VenuTOP 100Posted Jul 16, 2015, 11:50 PM EDT
Rahul Saxena Thanks buddy.
SharadPosted Jul 16, 2015, 11:35 PM EDT
good one...
Rahul Kumar SaxenaTOP 100Posted Jul 16, 2015, 11:22 PM EDT
Good show
Sibeesh VenuTOP 100Posted Jul 16, 2015, 8:47 PM EDT
Rakesh Chavda Thank you :)
Sibeesh VenuTOP 100Posted Jul 16, 2015, 8:47 PM EDT
Nilesh Jadav Thank you :)
Sibeesh VenuTOP 100Posted Jul 16, 2015, 8:47 PM EDT
Pankaj Kumar Choudhary Thank you :)
RakeshPosted Jul 16, 2015, 8:28 PM EDT
Good one
Nilesh JadavPosted Jul 16, 2015, 8:07 PM EDT
Nice one sir
Pankaj Kumar ChoudharyTOP 100Posted Jul 16, 2015, 2:43 PM EDT
Nice Explain Sir.......