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

dynamic add control

Hi all
The following code only work for the first click, if i click the
image button second time, it doesn't add a control dynamically. How to fix?
Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Session("numberOfUploadField") = Session("numberOfUploadField") + 1
Dim fileUpload As New FileUpload()
fileUpload.ID = "fileUpload" & Session("numberOfUploadField")
uploadPanel.Controls.Add(fileUpload)
End Sub
thanks
from Peter (cm****@hotmail.com)
Sep 8 '08 #1
2 2031
I guess it does add another control but you lose the first one between the
postbacks. If you need dynamically added controls to survive postbacks, you
need to add them in Page.Init or PreInit event.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Peter" <cm****@hotmail.comwrote in message news:48********@127.0.0.1...
Hi all
The following code only work for the first click, if i click the
image button second time, it doesn't add a control dynamically. How to
fix?
Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Session("numberOfUploadField") = Session("numberOfUploadField") + 1
Dim fileUpload As New FileUpload()
fileUpload.ID = "fileUpload" & Session("numberOfUploadField")
uploadPanel.Controls.Add(fileUpload)
End Sub
thanks
from Peter (cm****@hotmail.com)

Sep 8 '08 #2
On 9$B7n(B8$BF|(B, $B2<8a(B4$B;~(B41$BJ,(B, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
I guess it does add another control but you lose the first one between the
postbacks. If you need dynamically added controls to survive postbacks, you
need to add them in Page.Init or PreInit event.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

"Peter" <cmk...@hotmail.comwrote in messagenews:48********@127.0.0.1...
Hi all
The following code only work for the first click, if i click the
image button second time, it doesn't add a control dynamically. How to
fix?
Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Session("numberOfUploadField") = Session("numberOfUploadField") + 1
Dim fileUpload As New FileUpload()
fileUpload.ID = "fileUpload" & Session("numberOfUploadField")
uploadPanel.Controls.Add(fileUpload)
End Sub
thanks
from Peter (cmk...@hotmail.com)
you are right, i need to recreate every control in the page_load
thanks
from Peter
Sep 10 '08 #3

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

Similar topics

3
by: MikeY | last post by:
Hi Everyone, I am working in C#, windows forms.My question is this. All my button dynamic controls properties are present and accounted for except for the"FlatStyle" properties. I can't seem to...
3
by: Guy Harwood | last post by:
Hi, I have designed a textbox that inherits from the System.Windows.Forms.Textbox control. when the control is readonly the back color changes to a light blue to indicate that it is frozen. ...
6
by: MikeY | last post by:
Hi Everyone, Does anyone know where I can get my hands on a sample with source code of a simple dynamic button control in C# Windows form. I am looking for a sample that uses a class library...
2
by: Matt | last post by:
Hi, Can someone provide some information on how to create a control dynamically based on the contents of another dynamic control. In my experience, all dynamic controls must be created in the...
5
by: mytestemailaccount | last post by:
Hi, Hope you can help. I am relatively new to all this but would appreciate the groups help. The scenario: I am c# and asp.net to create a web application. The web page contains a user...
1
by: amirmira | last post by:
I have a multithreaded application is ASP.NET that checks the status of a process every 2 seconds. After the thread has completed, the values of dynamically added controls need to be changed...
2
by: dawg1998 | last post by:
I have a page that creates dynamic textboxes based on the number of fields a user chooses to fill out. This process worked great when the page was standalone. However, when I move to a...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
0
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all...
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: 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
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...
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
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...

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.