CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 3/4/2005 11:41:55 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 19 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
michaelpietsch
Asp.Net User
adding controls in response to PostBacks3/4/2005 11:41:55 PM

0/0

I am building yet another tree control - mostly for the fun of it. Plus I was unable to locate a _really_ simple one. Mine simply takes a non-normalized table for input and does nothing fancy at all...

However, nodes can be expanded and collapsed. Nodes are represented by LinkButtons which add or remove the node from a list of expanded nodes, represented by an ArrayList currently stored in the ViewState. I could also move it to the session-object.

Problem: At what point do I build my tree and instantiate my new LinkButtons?

I cannot do it before PostBackEvents have been processed , because what controls are added depends on the the LinkButton that was clicked.

I cannot do it in the PreRender phase either, because event-handling code has already been created at that point and my new LinkButtons will not be hooked up to events.

How would you go about this?

I can see two solutions:
1. Always create the entire tree and set the Visibility-property accordingly.
2. Resorting to handing info over through the querystring.

Any comment would be appreciated. I am still trying to figure ASP.NET out.....

Michael
miguelcastro67
Asp.Net User
Re: adding controls in response to PostBacks3/9/2005 3:34:42 PM

0/0

You should be using ViewState to persist the current state of the tree (basically what nodes are openned and closed). Then it should all be recreated in the CreateChildControls method (if this is a composite control). It is not good practice to try to access IsPostBack from a webcontrol and you should definately not be trying to access QueryString. It can be done, but you will be very tightly coupling your control to the page/site.
Good luck,
Miguel Castro
www.dotnetdude.com
michaelpietsch
Asp.Net User
Re: adding controls in response to PostBacks3/12/2005 9:25:48 PM

0/0

Hi Miguel,

I'm still totally lost. Or even more so.

I keep on running into situations where I need to add controls in response to postback-events.

According to the trace, events fire in the following order:
1. Page_Init
2. Page_Load
3. [PostBackEvents]
4. Page_PreRender

When Postback-Events are handled, it is already too late to add controls programatically. That is understandable, since controls have to exist in order to fire events. Therefore controls have to be added during Page_Init and Page_Load BEFORE PostBackEvents are fired. And that in turn means that controls cannot be added in response to PostBack, right?

I hate using the querystring, but it seems that is the only thing that can be influenced on the page (through simple links) and that's available during Page_Init and Page_Load.

Michael
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
ASP.NET AJAX Programmer's Reference: With ASP.NET 2.0 Or ASP.NET 3.5 Authors: Shahram Khosravi, Pages: 1522, Published: 2007
Developing Microsoft ASP.NET Server Controls and Components Authors: Nikhil Kothari, Vandana Datye, Pages: 689, Published: 2002
ASP.NET 2.0 All-In-One Desk Reference For Dummies: all-in-one desk reference for dummies Authors: Doug Lowe, Jeff Cogswell, Ken Cox, Pages: 910, Published: 2006
Beginning ASP.NET 2.0 AJAX: Written and Tested with the Final 1.0 Release Version of ASP.NET AJAX for ASP:NET 2.0 Authors: Wallace B. McClure, Paul Glavich, Scott Cate, Steve C. Orr, Craig Shoemaker, Steven A. Smith, Jim Zimmerman, Pages: 344, Published: 2007
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005
MCAD Developing and Implementing Web Applications with Microsoft Visual C#(TM) . NET and Microsoft Visual Studio(R) . NET Exam Cram 2 (Exam Cram 70-315): Exam Cram 2, McAd Exam 70-315 Authors: Kirk Hausman, Amit Kalani, Ed Tittel, Pages: 600, Published: 2003
Programming ASP.NET: Building Web Applications and Services with ASP.NET 2.0 Authors: Jesse Liberty, Dan Hurwitz, Pages: 930, Published: 2005
Beginning ASP.NET 3.5 in C# 2008: From Novice to Professional Authors: Matthew MacDonald, Pages: 954, Published: 2007
Beginning ASP.NET 2.0 in C# 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1148, Published: 2006
MCAD/MCSD.NET: Developing and Implementing Web Applications with Visual Basic.NET and Visual Studio.NET Authors: Mike Gunderloy, Pages: 1104, Published: 2003

Web:
CSS Control Adapters Cause Double PostBack in IE The second PostBack causes the controls to throw errors because the control changed the state of the system in response the first PostBack. ...
Composite Controls, eventhandlers and knowing which control caused ... Response.Write("Need to deciede which control event raised the postback
"); Control control = null; string ctrlname = Page.Request.Params. ...
control not found on postback - .NET ASP Controls.Add(txt); } } where control "test" is the form that i am submitting and all im trying to do is to debug.writeline "hi" on postback. ...
Finding a Repeater's controls during postback - Andrew Stevenson's ... Add("String_Date",typeof(string)); test.Tables[0].Columns.Add("String_Date2" ... Controls[0] as DataBoundLiteralControl; Response.Write(dbl.Text); Response. ...
ASP.NET.4GuysFromRolla.com: Building Interactive User Interfaces ... May 7, 2008 ... Performing Client Actions in Response to Partial Page Postbacks - learn .... The first step is to add an UpdateProgress control to the page. ...
ASP.NET postbacks and URL rewriting: Ruslan's Blog When a server side form control is added to the web page, ASP.NET will render the response with HTML tag that contains an action attribute pointing ...
Getting postback data from dynamically created controls Posted by: Abishek Bellamkonda on Thu Oct 13 22:37:51 EDT 2005 in response to Message #187435. If you add Controls Dynamically, .NET assumes that you should ...
Maintain control Values after PostBack - ASP.NET CheckAnswer(); if (ans) { result++; } } Response.Write(result);*/ } /// ... ID = "newc" + i.ToString(); this.Q_PlaceHolder.Controls.Add(newc); } } ...
Items Disappear after Postback - Infragistics Forums If you're adding the controls in response to a button click, ... very hard to add them again at the right time during subsequent postbacks. ...
InformIT: MCAD/MCSD: Implementing Navigation for the User ... Maintain values of controls and variables across page postbacks. ... Page class returns true when a page is being loaded in response to a client postback. ...




Search This Site:









 
All Times Are GMT