1

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?

Marek Grzenkowicz
  • 16,009
  • 8
  • 78
  • 100
Hari Gillala
  • 11,218
  • 18
  • 66
  • 116

2 Answers2

2

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

Marek Grzenkowicz
  • 16,009
  • 8
  • 78
  • 100
1

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.

Marek Grzenkowicz
  • 16,009
  • 8
  • 78
  • 100