473,386 Members | 1,721 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.

Persisting dynamic controls

Hi all,

My web form creates & displays dynamic controls when a user clicks a button
(code below). No problem. But how do I persist a new control? Every postback
destroys the object never to be seen again.

Dim MyNewImageButton as New System.Web.UI.WebControls.ImageButton
:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
myNewButton.ImageURL = "http://...../someimage.jpg"
Me.FindControl("Form1").Controls.Add(myNewImageBut ton)
End Sub

Any pointers?

Thanks.

- Assaf

Nov 18 '05 #1
2 1628
Inherently, it will be destroyed as "Page" processing completes after the
page is loaded.
You can simulate a "perceived" persistence by keeping the control's property
with a server-side "flag" value that indicates that it should be persisted
at the point specified and basically regenerate the control at each postback
based on this flag value (regenerate if "persists" else do nothing kinda
deal).

Hope this helps.
/js.

"Assaf" <at@isp.com> wrote in message
news:u%****************@TK2MSFTNGP12.phx.gbl...
Hi all,

My web form creates & displays dynamic controls when a user clicks a button (code below). No problem. But how do I persist a new control? Every postback destroys the object never to be seen again.

Dim MyNewImageButton as New System.Web.UI.WebControls.ImageButton
:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
myNewButton.ImageURL = "http://...../someimage.jpg"
Me.FindControl("Form1").Controls.Add(myNewImageBut ton)
End Sub

Any pointers?

Thanks.

- Assaf

Nov 18 '05 #2
Ram
You need to recreate all the dynamic controls every time you make a
post back. Put the dynamic control creation into a seperate rotine and
call it in init function.

"Assaf" <at@isp.com> wrote in message news:<u#**************@TK2MSFTNGP12.phx.gbl>...
Hi all,

My web form creates & displays dynamic controls when a user clicks a button
(code below). No problem. But how do I persist a new control? Every postback
destroys the object never to be seen again.

Dim MyNewImageButton as New System.Web.UI.WebControls.ImageButton
:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
myNewButton.ImageURL = "http://...../someimage.jpg"
Me.FindControl("Form1").Controls.Add(myNewImageBut ton)
End Sub

Any pointers?

Thanks.

- Assaf

Nov 18 '05 #3

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

Similar topics

8
by: John Smith Jr. | last post by:
I am looking for some way to persist a table web control so when page_load event comes up, i can display the table as it was. I tried using ViewState with the rows collection but that didn't work...
3
by: Stu | last post by:
Hi, I am creating a control in a PlaceHolder like so: Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim ctrl As...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
1
by: dougloj | last post by:
Hi, In my ASP.NET application, I want to be able to dynamically create RadioButtonLists and/or CheckBoxLists according to what is in my database. I wrote routines to create RadioButtonLists...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.