Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 February 23rd, 2009, 01:39 PM
Registered User
 
Join Date: Feb 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Advice wanted

My app needs to present web pages whose content is determined by previous user input - for example, the user enters "3" and the next page contains two radio buttons and a text box, but if he enters "4" it contains a text area and a drop-down list. Of course it's a bit more complex than this and I have a static definition held in a XML structure that defines what controls should be produced for each user input.

My initial thoughts were to use ASP and just use response.write to create the pages, but I wondered if it is possible to use ASPX in a dynamic way (things like client side validation would be useful). For example, would it make sense to generate ASPX code and compile it for each new page?

As a second issue, I was planning to create an object structure from the XML, but as I understand it I would have to do this at the start of each interaction (albeit from a cached version of the XML file). Is there a way to make a fairly complex object structure persist?
 
Old February 23rd, 2009, 02:06 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Is this related to the book Beginning ASP.NET 3.5? If not, you may be better off posting this in one of the general ASP.NET forums as more people are able to join the discussion.

Anyway, yes you can dynamically create controls. For example, try this:

1. Add a PlaceHolder control to a new page

2. Add this to the code behind:

TextBox myBox = new TextBox();
myBox.ID = "SomeID";
PlaceHolder1.Controls.Add(myBox);

Remember, you'll need to recreate the whole control hierarchy every time the page loads (that is, initial loads and postbacks). So, instead of pesisting it, you'll need to recreate it. Also be aware of submitted state. You typically need to create controls in an early event like PreInit.

For more info: http://www.google.com/search?hl=nl&q...le+zoeken&meta=

Another way is to create User Controls on the fly the first time the page is requested, then save them to disk as .ascx files and reuse them on subsequent requests.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP WANTED naana Visual Studio 2005 3 July 26th, 2007 03:45 AM
ADVICE WANTED: Which method is more efficient? kwilliams ASP.NET 2.0 Basics 3 August 31st, 2006 11:02 AM
SQL Server Advice Wanted kwilliams SQL Server 2000 1 June 27th, 2006 03:47 PM
ADVICE WANTED: Website Performance Issues kwilliams Classic ASP Professional 2 December 19th, 2005 04:13 PM
Query Wanted. irfan4 Access 1 July 15th, 2003 06:49 AM





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