System.Type.GetType();

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Josh

    System.Type.GetType();

    Hi Guys,
    I have hit a wall with the my project... The problem is that i need to get
    the type of a usercontrol that is not in the assembly of the page that is
    tryiong to call it. if anyone knows of how to fix this please let me know.

    c.setComponentP roperties(Reque st.QueryString["pageID"],"1");
    classname = c.cSrc;
    t = System.Type.Get Type(classname) ;
    uc = (UserControl)Ac tivator.CreateI nstance(t);
    ctl =
    uc.LoadControl( System.Configur ation.Configura tionSettings.Ap pSettings["virtualPat h"]
    + classname.Subst ring(classname. LastIndexOf("." ) + 1) + ".ascx");

    t.GetProperty(" ComponentID").S etValue(ctl,c.c ID.ToString(),n ull);
    PlaceHolder phPlaceHolder1 =
    (PlaceHolder)th is.FindControl( "Form1").FindCo ntrol("PlaceHol der1");
    phPlaceHolder1. Controls.Clear( );
    phPlaceHolder1. Controls.Add(ct l);
    string mode = "edit";
    litContentBegin .Text = "<div id=\"con\"
    onMouseOver=\"s howEditableArea (this);\"
    onMouseOut=\"hi deEditableArea( this);\"
    onClick=\"editC omponent('../siteadmin/components.aspx ?mode=" + mode +
    "&placeholderID =" + "1" + "&pageID=" +
    Request.QuerySt ring["pageID"].ToString() + "');\">";
    litContentEnd.T ext = "</div>";

    Thanks
    Josh


  • Scott Allen

    #2
    Re: System.Type.Get Type();

    Hi Josh:

    I'm not sure what you are trying to do exactly by looking at the code
    excerpt, or what is going wrong (is there an exception or error
    message?). However, I strongly suspect you don't want to be using
    Type.GetType and Activator.Creat eInstance. If you just pass the ascx
    file name to Page.LoadContro l you'll get back a reference to a user
    control that is instantiated and ready to be placed on a page. As it
    stands it looks like you are discarding this reference.

    --
    Scott



    On Fri, 17 Sep 2004 10:22:48 +1000, "Josh"
    <josh@rb.com.au REMOVETOEMAIL> wrote:
    [color=blue]
    >Hi Guys,
    >I have hit a wall with the my project... The problem is that i need to get
    >the type of a usercontrol that is not in the assembly of the page that is
    >tryiong to call it. if anyone knows of how to fix this please let me know.
    >
    >c.setComponent Properties(Requ est.QueryString["pageID"],"1");
    >classname = c.cSrc;
    >t = System.Type.Get Type(classname) ;
    >uc = (UserControl)Ac tivator.CreateI nstance(t);
    >ctl =
    >uc.LoadControl (System.Configu ration.Configur ationSettings.A ppSettings["virtualPat h"]
    >+ classname.Subst ring(classname. LastIndexOf("." ) + 1) + ".ascx");
    >
    >t.GetProperty( "ComponentID"). SetValue(ctl,c. cID.ToString(), null);
    >PlaceHolder phPlaceHolder1 =
    >(PlaceHolder)t his.FindControl ("Form1").FindC ontrol("PlaceHo lder1");
    >phPlaceHolder1 .Controls.Clear ();
    >phPlaceHolder1 .Controls.Add(c tl);
    >string mode = "edit";
    >litContentBegi n.Text = "<div id=\"con\"
    >onMouseOver=\" showEditableAre a(this);\"
    >onMouseOut=\"h ideEditableArea (this);\"
    >onClick=\"edit Component('../siteadmin/components.aspx ?mode=" + mode +
    >"&placeholderI D=" + "1" + "&pageID=" +
    >Request.QueryS tring["pageID"].ToString() + "');\">";
    >litContentEnd. Text = "</div>";
    >
    >Thanks
    >Josh
    >[/color]

    Comment

    Working...