user1314404
user1314404

Reputation: 1295

How to use load control from another page in c#

I have a file called "psstep2tabstrip.ascx.cs" where defines public partial class:

public partial  class PSStep2Display :Syntegra.Manufacturing.WMCCM.Web.UI.Components.WMCCMControl

in this file I can call:

PSStep2Display control = (PSStep2Display) LoadControl("~/WMCCM/PartnerSearch/PSStep2Display.ascx");

Now in my file companies.ascx.cs I make the same call:

PSStep2Display control = (PSStep2Display) LoadControl("~/WMCCM/PartnerSearch/PSStep2Display.ascx");

But it cannot recognize

 PSStep2Display

I already tried to include the header of "psstep2tabstrip.ascx" to the header of "companies.ascx":

   <%@ Reference Control="~/wmccm/partnersearch/psstep2display.ascx" %>
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls" %>
<%@ Control Language="c#" Inherits="Syntegra.Manufacturing.WMCCM.Web.UI.PartnerSearch.PSStep2TabStrip" Codebehind="PSStep2TabStrip.ascx.cs" %>

But it still cannot recognize. How could I correct this error here ?

Upvotes: 0

Views: 293

Answers (2)

ntl
ntl

Reputation: 1299

  1. To make it visible use using directive.
  2. If PSStep2Display is nested class you should reference it like ContainerClass.NestedClass.

Upvotes: 1

Sam
Sam

Reputation: 2917

You must use the name space of PSStep2Display control as a using directive if you'd like to use the control like

PSStep2Display control = (PSStep2Display) LoadControl("~/WMCCM/PartnerSearch/PSStep2Display.ascx");

Instead of that use it like this

Control control = LoadControl("~/WMCCM/PartnerSearch/PSStep2Display.ascx");

Upvotes: 1

Related Questions