473,405 Members | 2,262 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,405 software developers and data experts.

Loading controls

Can somebody show me how to load a control that has properties
programmically... in asp.net 2.0 i know how to do it in asp.net 1.1 but
asp.net 2.0 uses partial classes so casting doesnot take in effect
....what can i do ?

thank you in advance !
---
Best Regards
Amir

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #1
5 1170
The partial keyword should not change how you cast an object
reference, can you show us the code you are trying to use?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 20 Jun 2005 09:22:03 -0700, Amir Ghezelbash
<am*****@rogers.com> wrote:
Can somebody show me how to load a control that has properties
programmically... in asp.net 2.0 i know how to do it in asp.net 1.1 but
asp.net 2.0 uses partial classes so casting doesnot take in effect
...what can i do ?

thank you in advance !
---
Best Regards
Amir

*** Sent via Developersdex http://www.developersdex.com ***


Nov 19 '05 #2

Control ctlControl=null;
ctlControl = LoadControl("FeaturedProduct1.ascx");
((FeaturedProduct1)ctlControl).BackColor = "Yellow";

this casting doesnot work in asp.net 2.0 ...why ?

---
Best Regards
Amir

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #3
Hi Amir:

When you say it does not work do you mean there is a compilation error
or a run time exception?

Can you post FeaturedProduct1.ascx and .cs?

I've tried similar code without a problem, so I'm not sure where the
problem could be...

--
Scott
http://www.OdeToCode.com/blogs/scott/
On Wed, 22 Jun 2005 06:34:11 -0700, Amir Ghezelbash
<am*****@rogers.com> wrote:

Control ctlControl=null;
ctlControl = LoadControl("FeaturedProduct1.ascx");
((FeaturedProduct1)ctlControl).BackColor = "Yellow";

this casting doesnot work in asp.net 2.0 ...why ?

---
Best Regards
Amir

*** Sent via Developersdex http://www.developersdex.com ***


Nov 19 '05 #4

Hi sorry for the late response
the error i am getting is that it cant find the class to cast

the code i am using is
Control c1 =
LoadControl("~/Controls/MemberPageControls/Uploader/Email/DBUploader.asc
x");
((DBUploader)c1).CurrentCampaign = null;
PlaceHolder1.Controls.Add(c1);
i tried to put the cs code behind the ascx file into a namespace then
import that namespace but that gives me this error...any body any
idea..it would work if the aspx file is in the same dir as the actual
control i am trying to load up

the error===>

Error 4 'ASP.Hello.FrameworkInitialize()': no suitable method found to
override c:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\Temp orary ASP.NET
Files\website3\33dec574\6f269059\nhfoxkh2.0.cs 136
---
Best Regards
Amir

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #5
On Wed, 29 Jun 2005 11:46:23 -0700, Amir Ghezelbash
<am*****@rogers.com> wrote:

Hi sorry for the late response
the error i am getting is that it cant find the class to cast

the code i am using is
Control c1 =
LoadControl("~/Controls/MemberPageControls/Uploader/Email/DBUploader.asc
x");
((DBUploader)c1).CurrentCampaign = null;
PlaceHolder1.Controls.Add(c1);


Hi amir:

I'm on the same page now. The problem is this confusing compliation
model in ASP.NET 2.0.

Where does the above code reside? In a file in /App_Code or in the
code-behind for a web form?

If you are writing this in the code behind for a webform, you should
be able to add a VirtualPath in a @ Reference directive. See:

http://odetocode.com/Blogs/scott/arc...6/30/1889.aspx

If you are not inside a webform - it gets a lot tricker....

--
Scott
http://www.OdeToCode.com/blogs/scott/
Nov 19 '05 #6

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

Similar topics

5
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. ...
1
by: Angel | last post by:
Is there a way to display a message using an aspx page with controls on it that the data is loading for the page without having to display one html page then reloading the aspx page. in other words...
1
by: John Cosmas | last post by:
I've got a page which loads up a different user control into a placeholder control every time a button is clicked on the parent page. I use a statement like...
7
by: Tim | last post by:
I am trying to load both server and user controls into placeholder controls on a aspx template page at runtime. These values would be strings that are returned from a database query. I know I can...
0
by: Phl | last post by:
Hi, I am trying to create an webform which loads usercontrols dyanamically. I know exactly what to load for some of these controls but for some, I dont want to load it until the user has press a...
1
by: RAJ | last post by:
Hi, I am working on a source code written earlier in VB.net.While loading some forms(already created with some controls on it), I am getting the following error:...
2
by: Dave A | last post by:
I just don't get this... If I need to dynamically load controls into a web page I simply need to go PlaceHolder1.Controls.Add(new Button()); or similar. However when I need to dynamically...
4
by: mrmagoo | last post by:
I'm building a vb.net Forms project that is getting data from a SQL Server database. One of the main goals of the project is to be really responsive to events, such as textbox change events. I...
1
by: Bob Rock | last post by:
Hello, I'm new to ASP.NET and I've been looking into the topic of dynamically loading (typically accomplished with a LoadControl followed by a MyControl.Controls.Add()) both user controls and...
2
by: adiel_g | last post by:
I added a user control to a webform in Asp.net 2.0. I am also adding several other user controls to this webform. Now I am trying to find a way to stop the user controls from loading up when I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.