<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Use User Controls In MVC &#8211; Sibeesh Passion</title>
	<atom:link href="https://mail.sibeeshpassion.com/tag/use-user-controls-in-mvc/feed/" rel="self" type="application/rss+xml" />
	<link>https://mail.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Wed, 02 Jun 2021 15:19:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>Use User Controls In MVC &#8211; Sibeesh Passion</title>
	<link>https://mail.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Create And Consume A User Control In MVC</title>
		<link>https://mail.sibeeshpassion.com/create-and-consume-a-user-control-in-mvc/</link>
					<comments>https://mail.sibeeshpassion.com/create-and-consume-a-user-control-in-mvc/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Tue, 14 Jul 2015 14:13:32 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Consume User Controls In MVC]]></category>
		<category><![CDATA[Create Controls in MVC]]></category>
		<category><![CDATA[Create User Controls]]></category>
		<category><![CDATA[MVC View]]></category>
		<category><![CDATA[Razor]]></category>
		<category><![CDATA[Use User Controls In MVC]]></category>
		<category><![CDATA[User Controls]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=7031</guid>

					<description><![CDATA[Introduction In this article we will learn how we can create and consume a user control in MVC. I hope you will like it. Background Today I got a requirement of working with CellSetGrid. Since it is supported with our normal Asp.Net web pages alone, I was in a need to convert the same to a user view control and consume it in MVC because my application is in MVC4. I have done the same. So I thought of sharing you that with you all. Using the code To do so, You need to follow the following steps. Add reference [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>In this article we will learn how we can create and consume a user control in MVC. I hope you will like it.</p>
<p><strong>Background</strong></p>
<p>Today I got a requirement of working with <em>CellSetGrid</em>. Since it is supported with our normal Asp.Net web pages alone, I was in a need to convert the same to a user view control and consume it in MVC because my application is in MVC4. I have done the same. So I thought of sharing you that with you all.</p>
<p><strong>Using the code</strong></p>
<p>To do so, You need to follow the following steps.</p>
<p><em>Add reference to your control DLL</em></p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/CreateAndUseAUserControlInMVC1new.png" alt="Create And Consume A User Control In MVC"/></p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/CreateAndUseAUserControlInMVC2.png" alt="Create And Consume A User Control In MVC"/></p>
<p><em>Add new Web User Control</em></p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/CreateAndUseAUserControlInMVC3.png" alt="Create And Consume A User Control In MVC"/></p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/CreateAndUseAUserControlInMVC4.png" alt="Create And Consume A User Control In MVC"/></p>
<p><em>Register your DLL reference</em></p>
<p>[html]<br />
&lt;%@ Register assembly=&quot;CellSetGrid2&quot; namespace=&quot;OLAPControls&quot; tagprefix=&quot;cc1&quot; %&gt;<br />
[/html]</p>
<p><em>Place your control</em></p>
<p>[html]<br />
 &lt;div&gt;<br />
        &lt;cc1:CellSetGrid2 id=&quot;csg2&quot; runat=&quot;server&quot; connectionstring=&quot;Data Source=&quot;Your DataSource&quot;; Initial Catalog =Your DB Name&quot;<br />
            cube=&quot;Your Cube Name&quot; height=&quot;800px&quot; width=&quot;1500px&quot; /&gt;<br />
&lt;/div&gt;<br />
[/html]</p>
<p><em>Change default namespace</em></p>
<p>Go to <em>ADODMGrid.ascx.cs</em> from the solution explorer.</p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/CreateAndUseAUserControlInMVC8.png" alt="Create And Consume A User Control In MVC"/></p>
<p>Change Namespace <em>System.Web.UI.UserControl</em> to <em>System.Web.Mvc.ViewUserControl</em></p>
<p><em>Create Controller</em></p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/CreateAndUseAUserControlInMVC5.png" alt="Create And Consume A User Control In MVC"/></p>
<p><em>Create a View</em></p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/CreateAndUseAUserControlInMVC6.png" alt="Create And Consume A User Control In MVC"/></p>
<p>Please make sure that you have selected a partial view </p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/CreateAndUseAUserControlInMVC7.png" alt="Create And Consume A User Control In MVC"/></p>
<p><em>Add the User Control to your View</em></p>
<p>[html]<br />
@Html.Partial(&quot;ADODMGrid&quot;)<br />
@* Here ADODMGrid is our user control name. No need to give its extension (ascx)*@<br />
[/html]</p>
<p>So here we are add our new web user control to our view. </p>
<p><em>Add tagPrefix to your Web.Config</em></p>
<p>Last but the least, you need to add tagPrefix to your web.config file as follows.</p>
<p>[html]<br />
 &lt;controls&gt;<br />
        &lt;add tagPrefix=&quot;cc1&quot; namespace=&quot;OLAPControls&quot; assembly=&quot;CellSetGrid2, Culture=neutral, PublicKeyToken=null&quot; /&gt;<br />
      &lt;/controls&gt;<br />
[/html]</p>
<p>You need to add teh above code under <em>system.web</em> &#8211;> <em>Pages</em></p>
<p>Now if your your view, you can see your control there 🙂</p>
<p><strong>Conclusion</strong></p>
<p>That is all. I hope you liked this article. Please share me your feedback.</p>
<p>Kindest Regards<br />
<a href="http://sibeeshpassion.com/" target="_blank" rel="noopener">Sibeesh Venu</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/create-and-consume-a-user-control-in-mvc/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
