I am a huge fan of using user controls in SharePoint. It makes the developers life easier since most good .Net devs should be VERY familiar with the concept. You get the UI designer in Visual Studio to make layout and placement of controls much easier. This can also lead to a richer user experience.
Now getting those user controls wrapped up in a web part and deployed is not always the easiest thing in the world. Thanks to the great Jan Tielens you can use the SmartPart. The SmartPart is great and I used it a lot when I was first starting out in SharePoint development. However I soon ran into situations where the SmartPart was not appropriate. Plus I hate to use third party controls where I don't have access to the source so I can really tweak it out. (*Note, Jan has released the source to at least a few versions of SmartPart so you can check out how he did things too!) So inspired by the great work done by Jan I decided to write my own web part that encapsulates user controls. I have used this part on several projects with great success. I will be releasing a sample project that contains a basic working sample of the techniques required to host a user control. This should be ready in the next few days.
Let me know if there are any specific needs and I will try and address them in the release, or in a follow-up release.
4 comments:
I am doing some development in sharepoint (new in this arena). I have created number of usercontrols. But the deployment to production server is not very clean. I generally copy ascx and ascx.cs to bin folder of the virtual path.
Do you have any suggestions for
deploying Usercontrol to production server from my virtual development server.
I will appreciate your suggestions.
Sure. I create a folder named 'UserControls' in the root of my site. I then copy all of my files into that folder. In 2003 that is just the .ascx file. In 2007 it would be the .ascx and the .cs file if you want to use run-time compile. If not you would place the ascx files in the UserControls folder and the .DLL files in the '_app_bin' folder.
Let me know if you have any other questions!
I am having a problem with the user control needing to be recompiled after IISReset or AppPool reset. Users who do not have admin access get "Unexpected Error" when they go to the site with the control on it. Once an admin goes to the site, the UC compiles and everyone can see the control after that.
I am using SmartPart with AJAX extensions as my control container.
-SmartPart dll is in the bin dir
-UC.cs and UC.aspx is in my usercontrols directory
Any idea on how I can precompile the UC or whats steps I need to go through to allow authenticated users the ability to compile without giving the complete control (over site or file system)?
Thanks,
Adam
Do you have the answer to this problem:
I am having a problem with the user control needing to be recompiled after IISReset or AppPool reset. Users who do not have admin access get "Unexpected Error" when they go to the site with the control on it. Once an admin goes to the site, the UC compiles and everyone can see the control after that.
Post a Comment