Re: System.Type.GetType();
From: Scott Allen (bitmask_at_[nospam)
Date: 09/17/04
- Next message: Phil Weber: "Re: MVC in ASP.Net"
- Previous message: Greg Burns: "Re: 1.1 sp1"
- In reply to: Josh: "System.Type.GetType();"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 16 Sep 2004 23:31:40 -0400
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.CreateInstance. If you just pass the ascx
file name to Page.LoadControl 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 http://www.OdeToCode.com On Fri, 17 Sep 2004 10:22:48 +1000, "Josh" <josh@rb.com.auREMOVETOEMAIL> wrote: >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.setComponentProperties(Request.QueryString["pageID"],"1"); >classname = c.cSrc; >t = System.Type.GetType(classname); >uc = (UserControl)Activator.CreateInstance(t); >ctl = >uc.LoadControl(System.Configuration.ConfigurationSettings.AppSettings["virtualPath"] >+ classname.Substring(classname.LastIndexOf(".") + 1) + ".ascx"); > >t.GetProperty("ComponentID").SetValue(ctl,c.cID.ToString(),null); >PlaceHolder phPlaceHolder1 = >(PlaceHolder)this.FindControl("Form1").FindControl("PlaceHolder1"); >phPlaceHolder1.Controls.Clear(); >phPlaceHolder1.Controls.Add(ctl); >string mode = "edit"; >litContentBegin.Text = "<div id=\"con\" >onMouseOver=\"showEditableArea(this);\" >onMouseOut=\"hideEditableArea(this);\" >onClick=\"editComponent('../siteadmin/components.aspx?mode=" + mode + >"&placeholderID=" + "1" + "&pageID=" + >Request.QueryString["pageID"].ToString() + "');\">"; >litContentEnd.Text = "</div>"; > >Thanks >Josh >
- Next message: Phil Weber: "Re: MVC in ASP.Net"
- Previous message: Greg Burns: "Re: 1.1 sp1"
- In reply to: Josh: "System.Type.GetType();"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|