473,388 Members | 1,426 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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.setComponentProperties(Request.QueryString["pageID"],"1");
classname = c.cSrc;
t = System.Type.GetType(classname);
uc = (UserControl)Activator.CreateInstance(t);
ctl =
uc.LoadControl(System.Configuration.ConfigurationS ettings.AppSettings["virtualPath"]
+ classname.Substring(classname.LastIndexOf(".") + 1) + ".ascx");

t.GetProperty("ComponentID").SetValue(ctl,c.cID.To String(),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
Nov 18 '05 #1
1 4783
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"
<jo**@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.Configuration Settings.AppSettings["virtualPath"]
+ classname.Substring(classname.LastIndexOf(".") + 1) + ".ascx");

t.GetProperty("ComponentID").SetValue(ctl,c.cID.T oString(),null);
PlaceHolder phPlaceHolder1 =
(PlaceHolder)this.FindControl("Form1").FindContro l("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


Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: elcc1958 | last post by:
I need to support a VB6 application that will be receiving disconnected ADODB.Recordset from out DotNet solution. Our dotnet solution deals with System.Data.DataTable. I need to populate a...
2
by: JohnnySparkles | last post by:
Hi everyone, I'm currently writing an application which uses the XmlSerializer class to serialize/deserialize objects to/from xml. Now when deserializing an XmlDocument back into the object,...
4
by: audipen | last post by:
I have a problem with System.Type.GetType method. If you try out the following code in C# console app .. System.Type t = System.Type.GetType("System.DateTime"); System.Type t1 =...
6
by: Jim Bancroft | last post by:
Hi everyone, I'm having some trouble with the code below. I receive a compile-time error on the second line saying "; expected": private static void myTestFunction(long myLong) { ...
2
by: TR | last post by:
Is it possible to use Type.GetType(...) with the types in the System.Web.UI.? My attempts always resolve to Nothing. Is this legal, or is the Web.UI assembly of the kind Type.GetType doesn't...
5
by: Don | last post by:
I have an array of System.type and I need to go through the array and perform different logic depending on the type stored in the array. I want to do: if (typeof typeCollection(i) is String)...
3
by: Imran Aziz | last post by:
Hello All, I am getting the following error on our production server, and I dont get the same error on the development box. Unable to cast object of type 'System.Byte' to type 'System.String'. ...
5
by: Lance | last post by:
I want to expose properties of a class to a user via a PropertyGrid class. Some of the properties are of type System.IO.FileInfo. Ideally, an OpenFileDialog window would appear when the user...
1
by: Sky | last post by:
Yesterday I was told that GetType(string) should not just be with a Type, but be Type, AssemblyName. Fair enough, get the reason. (Finally!). As long as it doesn't cause tech support problems...
1
by: Powers | last post by:
I currently have a large number of enums implemented into my Web Service. I am reworking the XML serialization of these enums. At present, each enum has hardcoded values, for example: xAttrs...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.