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 VenuPosted Jul 17, 2015, 5:57 AM
Gopi Chand Thank you
Gopi ChandPosted Jul 17, 2015, 5:40 AM
Nice one Sibeesh
Sibeesh VenuPosted Jul 17, 2015, 3:50 AM
Sharad Thank you
Sibeesh VenuPosted Jul 17, 2015, 3:50 AM
Rahul Saxena Thanks buddy.
SharadPosted Jul 17, 2015, 3:35 AM
good one...
Rahul Kumar SaxenaPosted Jul 17, 2015, 3:22 AM
Good show
Sibeesh VenuPosted Jul 17, 2015, 12:47 AM
Rakesh Chavda Thank you :)
Sibeesh VenuPosted Jul 17, 2015, 12:47 AM
Nilesh Jadav Thank you :)
Sibeesh VenuPosted Jul 17, 2015, 12:47 AM
Pankaj Kumar Choudhary Thank you :)
RakeshPosted Jul 17, 2015, 12:28 AM
Good one
Nilesh JadavPosted Jul 17, 2015, 12:07 AM
Nice one sir
Pankaj Kumar ChoudharyPosted Jul 16, 2015, 6:43 PM
Nice Explain Sir.......