CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 4/9/2004 6:14:36 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 24 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
dlavigna
Asp.Net User
Dynamic Controls4/9/2004 6:14:36 PM

0/0

Hello,

I'm fairly new to .NET and c# so I apologize in advance if this is a basic question :)

I'm having trouble using dynamic Controls and reading the associated user-selections in my code-behind:

I'm attempting to build a web application that presents to the user a dynamic list of questions and possible user-selected responses. The data-driven list of questions may each contain a True/False radio selections and/or a free form textbox (for instance). I'd like to display the questions in Step 1, re-present read-only versions of the questions and user selections upon submission in Step 2, and after the user confirms the validity of his/her selections, confirm the database write action in Step 3 - all three steps using the same .aspx page utilizing <ASP:Panel> objects to display and hide the objects for each of the steps.

To manifest these list of questions and the possible responses in Step 1 I decided to employ the use of a mixture of User Controls and basic Web Controls added to a Panel object via

MyPanel.Controls.Add( MyControl );

(I'm told there is little functional distinction in my context between the User Controls and Web Controls and it is really a design choice) - for instance I use Label and TextBox Web Controls and a User Control that contains a RadioButtonList for which I attach a DataSource dependent on the Question characteristics (this gives me a dynamic list of radio selections dependent on the characteristics of the Question - I was really pleased with how easy this was to do in .NET).

After much effort, I'm able to render my list of questions and possible responses successfully (recall I said I was fairly new to .NET and C# :) ). However, I run into trouble when I try to extract the user-selections from the Radio selections and the TextBoxes in Step 2. I've tried to pull the dynamic objects from my Panel via

MyPanel.FindControl("MyObjectId")

but to no avail. Also, I've tried to loop through the Panel objects via

foreach(Control tmpControl in MyPanel.Controls)

I've tried this in my submit action callback routine as well as an overriding OnPreRender routine but this doesn't quite work either. (I can successfully loop through the dynamic panel objects when Rendering the page for Step1 but this doesn't work when rendering Step 2 because I've remove the user-selection objects from Step1 so I can make room for the display of the read-only user-selection values for review in Step 2 - the trouble is I can't seem to extract the user-selections from Step 1 for display in Step 2.)

I've also tried to loop through MyPanel.Controls in Page_Load and, again, when transitioning from Step 1 to Step 2 I'm not seeing the dynamic objects.

I must be doing something wrong because this seems like a pretty basic capability to have: adding dynamic controls to a panel and being able to extra user-selections. What I'm I doing wrong? Should I be looping through my panel in another event routine? Let me know if any code snipets would be illustrative.

Thank you, thank you, thank you!

David
master4eva
Asp.Net User
Re: Dynamic Controls4/9/2004 8:38:59 PM

0/0

Hi David,

First of all, at least you do not have the "ignorance" of not trying. Whether or not the question is basic or not, people are always glad to help the people you try their hardest on their side... and I admire that facet -- I do get annoyed with the simple questions but the reason is that most of the people have an attitude attached to their posts (it is worse than being just lazy). And this is why I post so much -- to find rare people like you.

Ok, to the question at hand. What I would have done is built a composite control. But nevermind, there will just be more "ugleness" attached :-) . What you have to do, when you hit step two, is recreate the same form that you did in step one first (there must be no deviations). And from here is when you create your second "page". To get the values from step one, you can do it the two ways that you have mentioned above.

And by now, you will probably be asking "why recreate the step one in step two? It will just show step one amongst step two..." Ah - this is where some really nice magical code gets splashed up. Put the following code in your page:

protected override void OnPreRender(EventArgs e) {
stepOnePanel.Visible = false;
base.OnPreRender(e);
}

I think that will solve your problem with the side-by-side display which you probably picked up on in the second paragraph of the post.

Yours,
Justin
-- Justin Lovell
dlavigna
Asp.Net User
Re: Dynamic Controls4/10/2004 2:21:37 AM

0/0

Hi Justin,

Your suggestion has certainly helped me move the ball a bit further down the field :). I recreated the panel objects during Step 2 using the same routine originally used in Step 1 and included the OnPreRender() routine you suggested. The good news... I can now "see" all of the objects I created using the foreach() loop (oddly the FindControl() method still does not return a 'hit'). When stepping through in debug mode I can see each of my attempts to pull values from each of the dynamic objects. The bad news... the values don't seem to contain the user-selections from Step 1. It is as though the objects were re-initialized when I recreated them at the start of Step 2. (By the way, the OnPreRender() routine successfully removes the Step 1 panel - pretty cool).

Is there something else I need to do to have the re-created objects "grab" the user-selections from Step 1?

Thanks again in advance Justin. By the way, I've been reading these forums for only a week or so but I see your name everywhere :) I for one certainly appreciate the "volunteer" work you do for everyone :)

David.
dlavigna
Asp.Net User
Re: Dynamic Controls4/10/2004 6:47:15 AM

0/0

Hi Justin,

I had another opportunity to work on this since my last posting. I took you suggestion to heart about re-creating the dynamic objects "exactly" the same way in Step 2 as was done in Step 1. While I was using the same routine to re-create I was doing it in different event handlers. So I moved the re-creation routine call to the Page_Load routine so the objects are created each time through (with the hiding of the Step 1 panel in the OnPreRender() routine as you suggested originally it was not a worry about re-creating "too often"). When I tested it with the re-creation if the Page_Load all works perfectly!!! I can see the user-selections displayed in my Step 2 panel! From here it should be rather trivial to manipulate and utilize the user-selections as originally hoped.

Thanks again for setting me on the correct path!

Cheers!

David.
master4eva
Asp.Net User
Re: Dynamic Controls4/10/2004 8:49:46 AM

0/0

Glad that I could help out David. Have fun!
-- Justin Lovell
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Structural Dynamic Systems Computational Techniques and Optimization: Dynamic Analysis and Control Techniques Authors: Cornelius T. Leondes, Pages: 259, Published: 1999
Excel Hacks: 100 Industrial Strength Tips and Tools Authors: David Hawley, Raina Hawley, Pages: 283, Published: 2004
Instrument Engineers' Handbook: Process Control and Optimization Authors: Bela G. Liptak, Pages: 2464, Published: 2005
Dynamic Spin Chemistry: Magnetic Controls and Spin Dynamics of Chemical Reactions Authors: Saburō Nagakura, Hisaharu Hayashi, Tohru Azumi, Pages: 297, Published: 1998
Differential Geometry and Control: Summer Research Institute on Differential Geometry and Control, June 29-July 19, 1997, University of Colorado, Boulder Authors: Guillermo Segundo Ferreyra, G. Ferreyra, R. Gardner, H. Hermes, H. Sussmann, Pages: 341, Published: 1997

Web:
Dynamic Controls Inc.
TRULY Understanding Dynamic Controls (Part 1) - Infinities Loop This really blurs the line between static and dynamic controls, as it should. .... Part 4 of my series on Truly Understanding Dynamic Controls in ASP.NET. ...
ASP.NET.4GuysFromRolla.com: Dynamic Controls in ASP.NET Aug 14, 2002 ... This article, by Scott Mitchell, examines how to create dynamic controls on a Web page, and how to recursively iterate through the list of ...
ASP.NET tips: Golden rules for Dynamic Controls. The above code works fine, but a common mistake is to try to conditionally load dynamic controls, if we tweak the code a little bit you will notice we loose ...
Videos : The Official Microsoft Silverlight Site However, you can put a Canvas inside of a grid. As long as the Canvas is the parent of the Dynamic control things can move easily. ...
TRULY Understanding Dynamic Controls by Example - Infinities Loop Many of the comments I've received in the various dynamic controls entries ... Hopefully that helps with not only understanding dynamic control scenarios, ...
ASP.NET.4GuysFromRolla.com: Dynamic Web Controls, Postbacks, and ... Sep 29, 2004 ... This article, by Scott Mitchell, looks at dynamically loading Web controls whose values can survive postbacks.
ASP 101 - Storing Data from Dynamic Controls Using ASP.NET 2.0 ... Storing Data from Dynamic Controls Using ASP.NET 2.0 Callback ... This makes sense, after all without the controls the viewstate data for the controls has ...
Excel Dynamic Controls Sample This sample runs only in Microsoft Office Excel 2007.
Dynamic Control Oct 7, 2008 ... The most trusted name for ultimate sound and noise control. Acoustic solutions for car audio, hot rods and home theater.

Videos:
BMW Dynamic Stability Control Overview Dynamic Stability Control is an innovative technology that combines the functions of traction control, braking enhancement, and cornering ...
NCAA March Madness 08 Dynamic Post Control Tutorial pt 1 Offensive Tutorial.All new controls let players post up like never before.
Technical Briefing Number 6 - Third and Fourth Dynamic Hats the people who are in power on the planet believe that if they could control what you think, then you are totally under control. And in actual ...
NCAA March Madness 08 Dynamic Post Control Tutorial pt 2 Defensive Tutorial.All new controls let players post up like never before.
BMW Dynamic Performance Control (Animation) www.alle-autos-in.de - Dynamic Performance Control, entwickelt von ZF und BMW, soll Autos künftig sicherer und präziser um Kurven bringen. Das ...
Subaru Vehicle Dynamic Stability Control (VDC) explained Find out how Subaru VDC stability control works.
Mechatronics Mechanical System Control - It's the Software! Google Tech Talks September 21, 2006 David Auslander ABSTRACT The history of mechanical system control is one of striving for ever greater ...
BMW Dynamic Performance Control Technology Guide Dynamic Performance Control switches power between the left and right rear wheels to stabilise the vehicle within milliseconds and help increase ...
Dynamic Deeds Media: dynamic control image upload tutorial The is a tutorial that explains how to add an image to your Dynamic Control website. More info: http://dynamicdeeds.com
ACT pt2: Dynamic Control of Effects, Instruments, and Mixing SONAR 6's innovative new Active Controller Technology™ will forever change the way you work with instruments, effects, and mixing. Hosted by ...




Search This Site:










custome controls, javascript, and firefox/mozilla

amazon web services: hosting a .net website on the elastic computing cloud

custom designer & getting website project references (vs05b2)

spla related question

adding a property/attribute in custom control

error deploying web parts with chart fx

load postback data on a event-created child control

dynamically adding user controls

nice, april specials at crystaltech

best antivirus software to protect a windows 2003 server ?

control panel graphics

a security control (not newbie but new at this part)

looking for web hosting

simple colorpick control

installing iewc-control (treeview...etc.) -problem ?

custom datagridcolumn

dynamic custom controls and viewstate

discountasp.net new server help.

calendar control

problem loading control into toolbox

looking for "wsiwyg" text editor for bbcode

implementing autoformat

typeconvertor problem

suggest all validators include property for required

web hosting for .net 1.1 and mssql server

composite control and client ids

need help very badly

how to pass values from .ascx control to aspx.cs page

getting submitted value from composite control

custom controls and code render blocks

  Privacy | Contact Us
All Times Are GMT