Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 9th, 2006, 08:21 AM
Registered User
 
Join Date: May 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating Conrols dynamically

hi all please i want to create a textbox dynamically ie when a user clicks a button it should create a text box. this is the code i have so far
<%@ Page Language="c#" %>
<script runat="server">
 void Create() {
  TextBox mytxt = new TextBox();
  mytxt.ID="text1";
  mytxt.Visible="true";
  mytxt.Enabled="true";
  form1.Controls.Add(mytxt);
<html><head></head>
<body><form id="form1" runat="server">
<asp:Button id="btn" runat="server" OnClick="Create"/>
</form></body></html>
My problem is that this code seam not working. Some should please check the codes to see where my mistakes are


 
Old February 9th, 2006, 11:40 AM
Friend of Wrox
 
Join Date: Feb 2006
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403
Default

I am not very sure but try OnClick="Create()"

Gaurav
 
Old February 10th, 2006, 12:51 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

How this compiles I don't even know. form1.Controls.Add() is invalid syntax. You need Me.Controls.Add()

 
Old February 13th, 2006, 01:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

I would use a panel to add controls to also, so that you can control where the controls are being added at. Also, you would have to reload every time the page loads.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a presentation dynamically bala24 ASP.NET 1.x and 2.0 Application Design 0 April 21st, 2008 05:28 AM
Dynamically creating TemplateField.... aekta ASP.NET 2.0 Professional 1 March 19th, 2007 02:26 PM
Creating Xpath Dynamically ajayreddy2105 XSLT 2 February 20th, 2007 08:30 AM
dynamically creating control rahulpokharna Pro VB Databases 1 January 10th, 2006 04:41 PM
Creating controls dynamically Renu ASP.NET 1.0 and 1.1 Basics 9 December 19th, 2004 10:21 AM





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