tags:

views:

622

answers:

2

Hi,

I have a use control which contains some ajax functionality. I made all necessary changes to make my site ajax compatible (i.e added respective tags in web.config) which works fine. I am using smart part to load this user control. But when i click on open the tool pane for the smart part it is giving me following.

Could not open user control path: System.UnauthorizedAccessException: Access to the path 'C:\Inetpub\wwwroot\wss\VirtualDirectories\5252\UserControls' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption) at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption) at System.IO.Directory.GetFiles(String path) at SmartPart.UserControlToolpart.RenderToolPart(HtmlTextWriter output)

Please help me out to solve this error..

+2  A: 

This is happening because you have put the user control in a folder at the root of the site which SharePoint won't have access to.

Typically when you deploy a user control in SharePoint you put your control in the CONTROLTEMPLATES folder which is mapped to the ~/_controltemplates virtual directory in IIS, by default SP has access to this folder.

You can then put a SafeControl entry into your web.config for this folder

  <SafeControl Src="~/_controltemplates/*" IncludeSubFolders="True" Safe="True"    AllowRemoteDesigner="True" />

The folder is located at <12HIVE>/TEMPLATE/CONTROLTEMPLATES on the file system.

Lee Dale
Hi Lee Dale thanks for your reply..but my site is using form based authentication. can u explain me how to use ajax based user control with help of smart part in form based authentication site. Or how FBA user can get read write access to the userControls folder...?
Sachin
I'm not sure exactly what the problem is as AJAX has nothing to do with having FBA or NTLM authentication. To enable AJAX to work you will need the necessary web.config modificaions, then you need to add a <ScriptManager /> tag to either the page layout or the master page then surround the control in an update panel.FBA shouldn't affect this since the FBA user will be a member of the site and therefore be able to run in the SP context.
Lee Dale
Hey Lee thanks for helping me but The setting needs to be done to work ajax fine has been done successfully. What i want is how to use smart part in form base authentication site. Because Smart part is giving me error to access the path 'C:\Inetpub\wwwroot\wss\VirtualDirectories\5252\UserControls' where the user control is located. I have try to put the user control in controltrmplate folder but later on i found that the smart part refers to 'C:\Inetpub\wwwroot\wss\VirtualDirectories\5252\UserControls' path to load the user controls. This work fine in NTLM authentication site.
Sachin
A: 

I had the same problem sometime back. Its more of the issue with the how the SmartPart works. It has the UserControlPath always pointing to the usercontrol path.

As per Jan (creator of SmartPart) comment you can change that in the DWP file. What you can do is to deploy the weppart and export the WebPart, open the dwp/webpart file in notepad, search for the text UserControlPath replace with your path. Upload the webpart back to sharepoint with different name and use the new webpart

One Issue is that it works for first time and again when I try to Edit or change the user control it changes back to the /UserControl.

What I have done to solve is took the copy of the code from Codeplex and made the UserControlPath property browsable true so that the path will be visible in the toolpart of the web Part.Below code snippet is present in the SmartPart.cs

    [Browsable(true),

    WebPartStorage(Storage.Personal)]
    public string UserControlPath {....}
Kusek