Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 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 March 25th, 2009, 06:09 PM
Registered User
 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamically Add Button Error

I'm trying to dynamically add a button on the OrderHistory.aspx page.

Getting this error message:
Control 'buttonDownload' of type 'Button' must be placed inside a form tag with runat=server.

There is a form tag in the masterpage. I have tried to place another form tag on the OrderHistory.aspx but of course you I get an error message that states only one form tag is allowed.

I do not how many buttons that the page will need is the reason that I'm trying to add buttons dynamically.

There is a number of products that are mp3 files and I thought that the best place to allow the customer to download the files would be in the OrderHistory page.

Below is the code that I am testing with just to try to add one button.

Dim objButton AsNew Button
objButton.Text =
"Click me!"
objButton.ID = "buttonDownload"
Page.Controls.Add(objButton)
 
Old March 25th, 2009, 06:18 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
Default

OK if you just want to whack buttons on the page, then you can use
Code:
Page.Form.Controls.Add(objButton)

Just using Page.Controls will add it after the form and hence be outside of it.

I would have thought you would want to lay them out more nicely tho, for example putting them next to the song names or something. You might want to look into using one of the built-in binding controls such as a GridView or DataList

HTH
Phil
 
Old March 26th, 2009, 05:37 AM
Registered User
 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

philip_cole,

Thank you for your help. Your response has set me on the right way.

You were correct in stating that the button should be next to the downloadable product.

In testing I was just adding some test buttons using page.add.controls() - my mistake.

James





Similar Threads
Thread Thread Starter Forum Replies Last Post
error when I add print button for printing a repor canyonsettingsun Access 3 July 20th, 2006 01:04 PM
Add Push button or Check Box in outlook add-ins capdevs VS.NET 2002/2003 0 January 7th, 2006 08:51 AM





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