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

Changing controls after event fires.

At postback time, the controls are all recreated before an event fires. If
the event determines that some of the controls need to be replaced with
different controls that you can't create as invisible beforehand, how do you
go about it ? Can you force a re-run of the control creation step ?

Thanks
Adrian Parker
Nov 19 '05 #1
1 1244
Hi Adrian,

Welcome to ASP.NET newsgroup.
As for the creating new control after a certain postback event and make it
exist in all the sequesntial post(the control can't be precreated and set
to invisible), I think this is a common problem when developing a cutsom
web server control. Since Each dynamically created control should be
created and added into sub control's colletion in Page's Init or Load event
(before page processing postback events) so that those dynamic controls
can hanle their own postback events correctly( if they have postback
events). However, if we only create them in postback event or later,
they'll surely to disappear in the later request and event won't work
correctly.

Currently, as I've done in some former posts, the formal way is to provide
a certain flag value( can be a page's class member variable or control's
member is you are developing a custom control). That flag value should be
persisted into ViewState so as to remain between postback. Then, in our
page/custom control's Init or Load event, we create those dynamic controls
depending on the flag values. And we can set this flag value in postback
event(also modify the dyanmic controls). Then, in the sequential
post/request, those dynamic controls will always be created since the flag
value is set in the viewstate.

Here is a former thread discussing on the similiar problem:

http://groups.google.com/groups?thre...msftngxa10.phx.
gbl&rnum=1&prev=/groups%3Fq%3Dasp.net%2Bdynamic%2Bcontrol%2Bpostbac k%2Bsteve
n%2Bcheng%26hl%3Dzh-CN

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #2

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

Similar topics

4
by: Ant | last post by:
Hi, I'm a Vb6 developer just getting into .Net & I like it! But... How do I change the name of a control, say, a button, once code has been written to it. Even if I delete the old event,...
1
by: Henke | last post by:
Hello, I have one ImageButton controls which I initialize in Page_Load and declare on class level. ImageButton save = new ImageButton(); save.ImageUrl = "save.gif" save.Click += new...
1
by: Lamont Adams | last post by:
Hi all, I've created numerous custom controls of varying complexity, but I've been on this problem for a day and a half, and I can't figure this mystery out. I hope one of you kind folks can...
6
by: Adrian Parker | last post by:
I have a form with some controls on it, one of them has an auto postback onchange. So the postback occurs but before the event fires, all the controls are recreated. so my question is, if the...
2
by: Ben Amada | last post by:
I'm a little confused about in what Event should I add dynamic controls and in what Event should I retrieve the value of a dynamic control on postback. I've found that adding dynamic controls in...
2
by: MLS | last post by:
The documentation on dynamic handlers comes across as abiguous. Perhaps somebody could help set me straight? I have a situation where I need to dynamically create several usercontrols of the...
8
by: novus | last post by:
Hi, In ASP.net 2.0 I make a control which add the same controls dynamically. In the oninit event I add the controls to the controls collection. After that the loadviewstate event fills in the...
2
by: tfsimes | last post by:
Hi, I am a long time ASP developer learning .NET, so please bear with me. I am trying to find an article or such that will help me understand how to change control properties at runtime based on...
3
balabaster
by: balabaster | last post by:
I've got a user control that builds a table of dynamic data based on a :LINQ class holding the data. The data is loaded using the LoadData(DataInstance) method. The table it builds contains a...
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...
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
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
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.