Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created usercontrol (.ascx) as a webpart. When I deployed it, I got a prompt for login and 401 error.

The error occurs when I call Me.CreateChildControls().

Help Please.

I created a class that inherits WebPart. Here is my code in VB.

Imports Microsoft.SharePoint.WebPartPages

Public class UserControlWebPart
    Inherits Webpart  
Protected Overrides Sub CreateChildControls()<br>
    Dim control as MyPage = Me.Page.LoadControl(mycontrolpath)<br>
    Control.add(control)<br>
    Me.CretaeChildControls()<br>     
End Sub

Protected Overriedes Sub RenderContents(Byval writer as System.Text.HtmlWriter)<br>
    Me.RenderContents(writer)<br>
End Sub<br>
End Class

I followed example from this site, http://www.codeproject.com/KB/sharepoint/SharepointWebPart.aspx; everything is working. I'm rewrite the code in Vb because all my current .ascx are written in vb. This is when I ran into permission issue (note: no permission issue with c#)

share|improve this question
add comment

1 Answer

401 means access denied.

Check that the user that you are using to deploy and run your webpart has enough rights.

Also, are you calling CreateChildControls() from OnInit instead of from OnLoad?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.