Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 11th, 2005, 11:51 AM
Registered User
 
Join Date: Dec 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic HTML controls

I have a data entry screen with several textboxes and dropdownlists. It handles multiple tasks. Depending on the task selected, certain controls are made visible and enabled while the others and not. My question; is there a way to display the visible controls together at the top of the screen rather than their predefined position at runtime?
Thanks for any help,
Michael Stevens
 
Old January 14th, 2005, 05:06 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Is your page using Grid layout? If this is the case then your controls will always be where you put them in the designer. However, if you make the page with flow layout and you change the visibility of controls, the controls after those invisibile controls will slide up/over to take their place in the flow of the page.
 
Old January 18th, 2005, 06:55 PM
Registered User
 
Join Date: Dec 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply Planoie, I am now using a table defined in the HTML and as the panel is being defined in Page_Load I'm trying to create various controls on the fly in the table cells, depending on the panel called for. The controls appear correctly, but I'm not having any luck getting them to connect to an event handler. In Page_Load, I add a row to the table, add cells, create a button, enable it and add it to a cell. I then connect it to an event handler,
b1.Click += new System.EventHandler(button1_Click);
and throughout the rest of the Page_Load, using the Quick View, the button seems to be aware of the handler. When I click it, however, it is not seen. I am programming in C#. Thanks for any help.
Michael Stevens


 
Old January 20th, 2005, 03:35 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

When you create controls on the fly, you need to create them every time the page is loaded in order for their events to be fired properly. Are you adding the rows/cells/buttons on every page hit?

-Peter
 
Old January 21st, 2005, 04:34 PM
Registered User
 
Join Date: Dec 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Peter. No. Picture a table row with 3 cells containing a textbox, button and dropdownlist, respectively when the page is displayed. I would like to be able to add text to the textbox, click the button and move the text to the dropdownlist several times. When I load the page each time, the event handler fires but the textbox doesn't seem to be visible in the event handler. If I don't rebuild the table, the event will not fire. Steep end of the learning curve. Thanks, Michael.

 
Old January 27th, 2005, 09:09 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Mike, sorry for the delay in responding to this thread. Have you had any success?

Can you post your page_load code?

If your goal is to have several options for what's on the page, you can place each option in a panel and just turn the right panel on when appropriate. You mentioned using a panel above, but it seems you are adding the controls dynamically. Dynamic control creation is very tricky because of the way the page restores viewstate the control hierarchy. I've found that multi-phase/mode pages work best with placeholders or panels that you turn on and off.

-Peter
 
Old February 8th, 2005, 02:03 PM
Registered User
 
Join Date: Dec 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Peter, Thanks for your response. Due to production needs, I had to scrap the original Page_Load and move on to plan B, which was your suggestion from 1/14 of adding all controls and playing with their visibility. That works fine, although I'm carrying the overhead of 50 odd invisible controls at any one time.

 I haven't given up on the dynamic control idea, but I'll have to pursue it in my free time.

Forgive my terminology shortcomings, I'm pretty new to C# and .Net. I meant page, not panel in my previous post. I'll look into your panel suggestion and do some further viewstate research.

Again, thanks.
Michael






Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Dynamic Controls rhd110 General .NET 1 July 22nd, 2007 04:23 AM
Dynamic Controls with Database. carumuga Classic ASP Professional 0 February 1st, 2007 12:53 AM
Create dynamic controls saulodet C# 2 November 21st, 2003 12:36 PM
Dynamic Controls [xx(] koneruvijay VS.NET 2002/2003 0 November 12th, 2003 12:02 AM
Dynamic Controls tommyuk VB How-To 2 June 26th, 2003 12:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.