473,666 Members | 2,237 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Type.Get Type();

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
Nov 18 '05 #1
1 4802
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
http://www.OdeToCode.com
On Fri, 17 Sep 2004 10:22:48 +1000, "Josh"
<jo**@rb.com.au REMOVETOEMAIL> 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.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


Nov 18 '05 #2

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

Similar topics

0
2869
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 disconnected ADODB.Recordset from System.Data.DataTable data. Below is the source code I am implementing to test the process. I do not get any error, that I can see. The problem I have is that at the end, the recordset seems to be empty. Any...
2
3498
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, I'm using the System::Type::GetType(String* typeName) to create a Type* needed to construct the XmlSerializer. The typeName argument is taken from the XmlDocument and consists of the
4
12012
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 = System.Type.GetType("DateTime"); t is set to the appropriate Type object but the second call returns null (when I dont specify the namespace name)
6
19198
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) { System.Data.SqlTypes.SqlInt32 myTestInt;
2
3088
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 work with? Type.GetType("System.Web.UI.WebControls.TextBox", False, True) Thanks TR
5
1835
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) then 'some logic elseif (typeof typeCollection(i) is int32) then 'some logic .....
3
12985
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'. here is the code that I used to create a table and then add columns to it later, later I populate the rows in the table.
5
6531
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 attempted to edit the value of the System.IO.FileInfo properties. Is there an existing UITypeEditor that will do this type of thing, or will I need to create my own Thanks Lance
1
2148
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 down the line... What happens when my code is run on a station that only has framework 3.0 or 4.0, and this assembly, with version number defined for 2.0.0.0 , isn't available. ...breaks? Second question: Does an assembly's PublicKeyToken change...
1
5234
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 = New XmlAttributes xEnum = New XmlEnumAttribute xEnum.Name = "0" xAttrs.XmlEnum = xEnum
0
8355
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8550
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8638
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6191
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4365
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.