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

Incrementally create user controls

Hi,
I would appreciate if you could help me with my source code.
I want to create web user controls dynamically each time i press the
button.
But i only get one control each time. If i use a 'for'-loop then it is
no problem.

public Control c1;
private void Button1_Click(object sender, System.EventArgs e)
{

c1 = LoadControl("WebUserControl1.ascx");
((WebUserControl1)c1).Color="green";
FindControl("WebForm1").Controls.Add(c1);
FindControl("WebForm1").Controls.Add(new HtmlGenericControl("hr"));
}

Yours sincerely
Andla

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
1 1090
Each time you post back to the page, dynamic controls are not recreated. You
are going to have to keep track of all of your dynamically created controls and
re-instantiate them.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Andla Rand" <an******@yahoo.se> wrote in message
news:O0**************@TK2MSFTNGP12.phx.gbl...
Hi,
I would appreciate if you could help me with my source code.
I want to create web user controls dynamically each time i press the
button.
But i only get one control each time. If i use a 'for'-loop then it is
no problem.

public Control c1;
private void Button1_Click(object sender, System.EventArgs e)
{

c1 = LoadControl("WebUserControl1.ascx");
((WebUserControl1)c1).Color="green";
FindControl("WebForm1").Controls.Add(c1);
FindControl("WebForm1").Controls.Add(new HtmlGenericControl("hr"));
}

Yours sincerely
Andla

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #2

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

Similar topics

7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
0
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a...
0
by: Abra | last post by:
Is it possible to fill a ADO.NET dataset incrementally ? (I mean to call the DataAdapter Fill() method several times, as I did not found a Add() method) I would like to call in a background thread...
2
by: macca | last post by:
Hi, I am writing a GUI application. It will have a number of user defined controls( I plan to use/create a user defined control that will output alarm states that the user can also select and...
1
by: The Fox | last post by:
My VB.NET application will call a remote Web Service function that returns lots of data for reporting purpose. The data is finally binding to a DataGrid. It does take time! Is there any ways to...
3
by: Brian | last post by:
Hi, All, I want to create a single user control (component) with multi-controls. for example, I want to use one button control and 2 listBox controls to build one single user control. so, user...
8
by: robert | last post by:
Hello, I want to put (incrementally) changed/new files from a big file tree "directly,compressed and password-only-encrypted" to a remote backup server incrementally via FTP,SFTP or DAV.... At...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. 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
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
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...
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...
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.