473,395 Members | 1,473 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,395 software developers and data experts.

Dynamically Added User Control

I have a solution with 2 projects in it. I need to programatically
add a user control from one project into the other one (as you cannot
declare this normally on the form because it is in a different
application). When the page_load event of the user control is fired at
run-time, none of the form objects on the user control exist.

Is this a namespace issue? Or can you just not share a user control
over 2 projects without having a copy in both projects.

Thanks,
Jenni

Jun 8 '07 #1
4 1400

<Je************@googlemail.comwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
>I have a solution with 2 projects in it. I need to programatically
add a user control from one project into the other one (as you cannot
declare this normally on the form because it is in a different
application). When the page_load event of the user control is fired at
run-time, none of the form objects on the user control exist.

Is this a namespace issue? Or can you just not share a user control
over 2 projects without having a copy in both projects.

Thanks,
Jenni
This should be easy. I would create a third project for the usercontrol.
Then from each of the other projects either reference the usercontrol
assembly or the usercontrol project depending on the level of debugging you
are doing. Then when the usercontrol has changes the other two projects
will automatically pick up the new version (if you open the projects and
build the project).

Hope this helps,
Lloyd Sheen

Jun 8 '07 #2
Thanks for the post.
The trouble is accessing the user control once it is in a seperate
project. I can reference it ok, but at run-time the control within
the user control do not exist.

Thanks,
Jen

Jun 8 '07 #3

<Je************@googlemail.comwrote in message
news:11*********************@k79g2000hse.googlegro ups.com...
Thanks for the post.
The trouble is accessing the user control once it is in a seperate
project. I can reference it ok, but at run-time the control within
the user control do not exist.

Thanks,
Jen
Do you mean that you have multiple controls within your usercontrol?

If so you must provide the method of accessing the controls. This can be
done with functions or readonly properties.

Hope this helps
Lloyd Sheen

Jun 8 '07 #4
Do you mean that you have multiple controls within your usercontrol?
>
If so you must provide the method of accessing the controls. This can be
done with functions or readonly properties.
I have form objects such as labels and text boxes in the user control
which I need to access. Here is my code -

HTML in user control -
<asp:image Height="33" AlternateText="Powered by WorldPay" Width="139"
ImageAlign="AbsMiddle" Runat="server" ID="imageWorldPay"></asp:image>

Code that gives the error in the code behind of the UC -
imageWorldPay.ImageUrl = "~/images/poweredbyworldpay.gif";

Code in the other project which loads the uc -
protected System.Web.UI.Control pricegridcontrol;
pricegridcontrol = new
LumleyJacobsSharedLibrary.controls.BuyingProcessPr iceGrid();
wlnav_pricegrid.Controls.Add(pricegridcontrol);

The code in the user control to set the ImageUrl does not work because
the label does not seem to exist. Is this a;ways the case when
dynamically adding user controls, or is there another way?

Thanks,
Jen

Jun 11 '07 #5

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

Similar topics

7
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically...
4
by: Bas Groeneveld | last post by:
I am developing an ASP.NET application part of which consists of a data entry wizard defined by entries in a data table - ie the controls on each page of the wizard are determined by definitions in...
4
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
7
by: Samuel | last post by:
Hi, I am building a page that makes use of user control as a templating technique. The following is that I have in mind and it is actually working: Root/ -- login.aspx -- login.aspx.vb --...
4
by: Jordan | last post by:
I need to dynamically add an ImageButton control to a user control and and do some server-side processing when the user clicks it. While I the ImageButton is added to the user control at runtime,...
5
by: Dennis Fazekas | last post by:
Greetings, I am creating a web form which will all the user to add an unlimited number of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to remove, and a "Save" button....
9
by: Chris | last post by:
I am dynamically adding a user control to each row in a gridview. The reason I am doing it dynamically is the user control is different depending on certain data in the gridview. The gridview...
1
by: jelle.huygen | last post by:
Hello, I have a problem in ASP.NET 2.0 with the viewstate of my dynamically added user control. I have reproduced the problem with a very simple user control and a very simple page. On my...
1
by: Shraddha | last post by:
Hi, I am adding some ASP.Net user controls (.ascx file) dynamically on the button click. The user control will get added as many times userhits the button. Now on the click of the submit button, I...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...

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.