473,395 Members | 1,658 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.

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 1629
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.