locked
Share Web User Controls RRS feed

  • Question

  • User-617212719 posted

    Hi everyone, first time posting here, so be gentle.smile

    I have as web solution with multiple projects. The main project (PSW.Web) needs to load controls from one of the projects (PSW.Library), which has these web user controls. The PSW.Web has the reference to PSW.Library. I did load the control successfully using the “Pre-Build” event command line and in the aspx, but I need to load controls dynamically, in code-behind and don’t want the controls being transferred into the folder in PSW.Web (from Pre-Build) and hard-coded in the aspx file.

    The oddity that I am having is displaying the control. I successfully get a message box to show when the control is loaded into a PSW.Web form, but it is never seen. I can not visibly see it. I tried w/o a placeholder, with a panel, div, etc., but it is never rendered to the screen, even though it successfully adds it in code-behind.

    Below is the code. Any help on why the control does not display would be appreciated. Again, the message box "Hello Page Load" pops up, but the control never shows in the placeholder.

    This is the WebUserControl in the PSW.Library project

    namespace PSW.Library.provisions
    {
        public partial class eligibility : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
                System.Windows.Forms.MessageBox.Show("Hello Page Load!");
    
            }
    
            #region Properties
            public RadWizard GetRadWizard
            {
                get { return this.RadWizardControl; }
            }
            public String GetClientID
            {
                get { return this.ClientID; }
            }
            public String GetHello
            {
                get { return "Hello Motto!"; }
            }
            #endregion
        }
    }

    This is the cs form in the PSW.Web project

    namespace PSW.Web.views.plans.docprovisions.provisions
    {
        public partial class eligibility : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {            
                Library.provisions.eligibility uControl = new Library.provisions.eligibility();            
                this.PlaceHolderContent.Controls.Add(uControl);
            }
        }
    }

    This is the aspx form in the PSW.Web project

    <div style="height: 100%; width: 100%; overflow: no-display; background-color: lightblue">
       <asp:PlaceHolder runat="server" ID="PlaceHolderContent" />
    </div>

    Monday, October 22, 2018 3:57 PM

All replies