1
votes

I have created a user control and tested it by adding it to the aspx page, it works very well.

I wrote the user control, so that I can use in my Sharepoint Portal.

I have created a sharepoint webpart project and added the following code to the method.

public class Nov059PM : System.Web.UI.WebControls.WebParts.WebPart
{
    Control _myControl;

    protected override void CreateChildControls()
    {
        this.Controls.Clear();

        _myControl = this.Page.LoadControl("~/usercontrols/Grid.ascx");

        this.Controls.Add(_myControl);
    }
}

I have placed the Grid.ascx in the C:\inetpub\wwwroot\wss\VirtualDirectories\myportno\usercontrols folder.

I have built the webpart and deployed it.

When I try to use it, it says:

Could not load type 'Grid.Grid'.

Source Error:

Line 1: <%@ Control Language="C#" AutoEventWireup="true" Inherits="Grid.Grid" %>

I am thinking, Inherits should be four part name. How do I generate four part name for the same?

2

2 Answers

2
votes

You deployed the .ascx file but forgot the assembly or the code-behind file that contains the Grid.Grid class.

1
votes

You have to add fully assembly version in

<%@ Control Language="C#" Inherits="Grid.Grid,Grid,Version=1.0.0.0,Culture=neutral,PublicKeyToken=PUBKEYTOKEN" %>

And put Grid.dll in GAC.

before that you have to apply SNK in Grid.dll.