locked
page cast issues from UCtl (Dynamicly loaded) on holder page, , referencing properties on Holder Page .. RRS feed

  • Question

  • User-9278154 posted

    The error:  (sometimes,...usually not after a reboot and otherwise clean compile)

     CS0246: The type or namespace name 'Drm_OPSMainForm' could not be found (are you missing a using directive or an assembly reference?)

    The Question: Is there any way arround this, a reason for it not compiling periodically??

     

     

    Error Source (code in UCtl)  

                      Drm_OPSMainForm mainPage = (Drm_OPSMainForm)Page; 

                     //  i.e.    ( in a UserCtl, when trying to cast to the owner page, to retrieve and/or set values there)


     

     

    Background to functioanality: 

    Holder page (Drm_OPSMain) has 2 left nav menus  and 2 Content panes, into which UserCtls are loaded via Menu Item clicked

     

    (Holder Page Drm_OPSMain)

    public partial class Drm_OPSMainForm : System.Web.UI.Page

    ...

    ...some persisted properties, other arb functions etc

    ...

    //Load user control onto page Drm_OPSMainForm

    public void LoadUserControl(string userControl)  //from a menu item click

    {

    Control selectedUserControl = Page.LoadControl(userControl);

     

        //Generate an Unique ID based the control path

    string uniqueID = this.selectedUC.Split('.')[0];uniqueID = uniqueID.Replace("/", "").Replace("~", "");

    selectedUserControl.ID = uniqueID;

    //Load control into Required ASP Panel

    //...and prevent controls from being loaded twice..weird error,..??

    if (destPane == "TopContentPanel")

    {

    if (TopContentPanel.FindControl(selectedUserControl.ID) == null)

    {

    TopContentPanel.Controls.Add(selectedUserControl);

    }

    }

    else

    {

    if (BottomContentPanel.FindControl(selectedUserControl.ID) == null)

    {

    BottomContentPanel.Controls.Add(selectedUserControl);

    }

    }

    }

     

     

     

    In the USerControl Code:...SetPageAndPaneProperties called from it's pageLoad event

    protected void SetPageAndPaneProperties()

    {

    Drm_OPSMainForm mainPage = (Drm_OPSMainForm)Page;

    //store the Pane and Name on itself (which handles the reloading correctly on postbacks into the correct pane of the main holder page,

    ParentPane = mainPage.destPane;

    thisUC = mainPage.selectedUC;

    //Set This Operation (by Id), and it's Associated Plan,...from the Main Holding Menu Page

    //user's Branch Id

    OpId = mainPage.selectedOpId;

    OpPlanId = mainPage.selectedOpPlanId;

    }

    Friday, July 4, 2008 10:30 AM

Answers

  • User481221548 posted

    Hi NNR

    Page_Load ist the last possible point to load dynamic controls.
    Use bettter Page_Init instead.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 8, 2008 7:39 AM

All replies

  • User481221548 posted

    Hi NNR

    Is there any kind of an indicator for this periodic compile error?
    The references Assemblies are everytime the same?

    Sunday, July 6, 2008 6:38 PM
  • User-9278154 posted

    Hi Peter,

     

    No to there being some kind of indicator and the same assemblies are referenced, none new ones added,..

    This morning after a few :Buildpages" specifically firstly the DRM_OpsMngr.aspx then the Usrcontrols it loads, and then build the site (successfully), then Set as start page and run and ignore the errors warning message, and run last valid compilation...Hey Presto,.. runs.

    5 minutes later, after changing a <Connection String>, and rebuild, it fails, no matter what i try, build pages, builds, view in browser etc ..crashes now everytime.

    Sometimes a reboot sorts it out, sometimes not.

    Makes me wonder if Page load is the right place to call the LoadControl,..thought I saw somewhere somethin bout Page_PreRender...to do with loading external Scripts and css for UControls,..maybe worth a try (will let you know any way)....jsut seriously weird that it does do this periodically.

    Neal (NNR)

    Tuesday, July 8, 2008 6:06 AM
  • User481221548 posted

    Hi NNR

    Page_Load ist the last possible point to load dynamic controls.
    Use bettter Page_Init instead.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 8, 2008 7:39 AM
  • User-9278154 posted

    Hi Peter,

     

    Tried that but no success. Still refuses to see the Base/Holder page class.

    Tried it in a stand alone project , which eradicated the problem.

    so I also tested checked all my referenced classes, but clean compilation (no warnings either,...maybe some of the Config settings in the main project

    are responsible !!??  (The standAlone test version has the default Web.Config loaded,...that being about the only difference i can think of at present)

     (that being included beneath....note it's not something I have had exposure to before so kinda clueless there...so possinbly dumb shot in the dark..proverbial straw clutch?)

    Thx for so far

    Neal

    e.g.

     

    <configSections>

    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

    <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

    <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>

    <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

    <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>

    <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>

    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>

    </sectionGroup>

    </sectionGroup>

    </sectionGroup>

    </configSections>

    Wednesday, July 9, 2008 9:42 AM