473,581 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1257
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%3Das p.net%2Bdynamic %2Bcontrol%2Bpo stback%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
1525
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, whenever I click on the newly named control, it brings me to the old controls click event. i found that if i manually change the event name to the new...
1
3335
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 ImageClickEventHandler(this.save_click); This ImageButton is added to a dynamic table which is also
1
1963
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 point out the really obvious and stupid thing I'm overlooking here. :) I have a custom control that provides a tasklist similar to what you get in...
6
1117
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 event requires you to replace a control with another type, e.g. replace a textbox with a date control, how do I get it to redo the form with the new...
2
2930
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 the Page Load event works, and I realize that I need to add the dynamic controls again on each postback. But if I'm trying to retrieve the value of...
2
3280
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 same type within a form. This usercontrol has some events associated with it. For example: Private Sub NewThingy()
8
2089
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 information on postbacks. The control can add and delete controls that is why on the postback I don't know how many controls there are. At the...
2
1798
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 the value in a field. For instance, if I want to add some text to a field in a GridView based on a boolean value in an un-shown field being...
3
4356
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 number of dynamic controls that themselves have postback/autopostback so the display of the control needs to be built at latest in the Page.Load event or...
0
7876
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8310
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3832
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2307
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1409
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1144
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.