Last post Feb 01, 2008 02:34 AM by shobhasomaradhya
Jul 24, 2007 01:22 PM|techtalktoe|LINK
I am trying to create a reusable user control.
I have created a VS2005 Solution, which has one Web Project. The .aspx file in the Web Project makes use of a new User control (.ascx) which is inside a sub-folder of the Web project. When I run the solution, the web project works as expected and the .aspx
renders the user control fine.
Now, using the 'Build->Publish website' option, I have built separate '.dll' libraries for the .aspx file and the .ascx file into a folder named 'output'. These libraries have their names like App_Web_*.dll.
I want to reuse the user control in another web application. So, I tried to reference the .dll that was created above for the user control into the Bin folder of my new web application. After doing so, I am not sure what should be the namespace that I should
include in the 'using' statement in my code behind for the new web app page. I opened the user control's App_Web_*.dll using the ILDASM utility and saw my user control's class name in it. But when I try to create an instance of the user contol class in the
code behind, it is asking for a missing assembly reference. Eventhough I add a reference to the User control's .dll to the Bin, it gives the same error.
Please help. (All I am trying to do is create a reusable user control).
Jul 25, 2007 01:54 AM|sujitm|LINK
You cannot create a User Control which can be used out of a DLL directly. You have to copy and paste the .ASCX file to the new project. You can use CompositeControls to create a distributable control.
Jul 25, 2007 11:43 AM|techtalktoe|LINK
Please refer to the below posts, I have successfully created a DLL out of a user control and now it is redistributable. This is an easier path compared to developing a custom server control.
http://weblogs.asp.net/scottgu/archive/2005/08/28/423888.aspx and http://blogs.msdn.com/davidebb/archive/2005/10/30/487160.aspx
Thank you for your interest!
Jul 26, 2007 02:23 AM|sujitm|LINK
I wasn't aware that this is possible. Many thanks.
Feb 01, 2008 02:34 AM|shobhasomaradhya|LINK
I am also facing in creating user control library (dll). I have created an asp.net web application with only one usercontrol, the application name is "TestControl" and no other projects (like class library) are connected.
When I pubish the project the dll is App_web_*.dll.
Why is it so?