ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Add Textbox" />
<asp:Panel ID="Panel1" runat="server" >
</asp:Panel>
</div>
</form>
</body>
</html>
C#
using System;
using System.Web.UI.WebControls;
using System.Collections.Generic;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
private List textboxes;
protected void Page_Load(object sender, EventArgs e)
{
PreRender += new EventHandler(_Default_PreRender);
textboxes = new List();
if(IsPostBack)
{
//recreate Textboxes
int count = Int32.Parse(ViewState["tbCount"].ToString());
for (int i = 0; i < count; i++)
{
TextBox tb = new TextBox();
tb.ID = "tb" + i;
Panel1.Controls.Add(tb);
textboxes.Add(tb);
tb.Text = Request.Form[tb.ClientID];
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
//create new textbox
TextBox tb = new TextBox();
tb.ID = "tb" + textboxes.Count;
Panel1.Controls.Add(tb);
textboxes.Add(tb);
}
void _Default_PreRender(object sender, EventArgs e)
{
//remember how many textboxes we had
ViewState["tbCount"] = textboxes.Count;
}
}
}
------------
private System.Windows.Forms.TextBox[] textboxes;
textboxes = new System.Windows.Forms.TextBox[2];
int cnt=0;
foreach (System.Windows.Forms.TextBox textbox in textboxes)
{
// the location on the form. you may need to play with this
// and it should change for each textbox
textbox.Location = new System.Drawing.Point(88, 50);
textbox.Name = "textbox"+cnt.ToString();
textbox.Size = new System.Drawing.Size(173, 20);
textbox.TabIndex = cnt;
textbox.Visible = true;
cnt++;
}
--------------
public partial class AGEP : IdealFramework.UI.Screen
{
TextBox[] TB1 = new TextBox[18];
public AGEP()
{
InitializeComponent();
}
private void AGEP_Load(object sender, EventArgs e)
{
int sub = 0;
int sub2 = 0;
while (sub < 18)
{
TB1[sub] = new TextBox();
sub2 = sub * 25 + 1;
TB1[0].Location = new Point(5, sub2);
pnlPmtArea.Container.Add(TB1[sub]);
sub++;
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Add Textbox" />
<asp:Panel ID="Panel1" runat="server" >
</asp:Panel>
</div>
</form>
</body>
</html>
C#
using System;
using System.Web.UI.WebControls;
using System.Collections.Generic;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
private List textboxes;
protected void Page_Load(object sender, EventArgs e)
{
PreRender += new EventHandler(_Default_PreRender);
textboxes = new List();
if(IsPostBack)
{
//recreate Textboxes
int count = Int32.Parse(ViewState["tbCount"].ToString());
for (int i = 0; i < count; i++)
{
TextBox tb = new TextBox();
tb.ID = "tb" + i;
Panel1.Controls.Add(tb);
textboxes.Add(tb);
tb.Text = Request.Form[tb.ClientID];
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
//create new textbox
TextBox tb = new TextBox();
tb.ID = "tb" + textboxes.Count;
Panel1.Controls.Add(tb);
textboxes.Add(tb);
}
void _Default_PreRender(object sender, EventArgs e)
{
//remember how many textboxes we had
ViewState["tbCount"] = textboxes.Count;
}
}
}
------------
private System.Windows.Forms.TextBox[] textboxes;
textboxes = new System.Windows.Forms.TextBox[2];
int cnt=0;
foreach (System.Windows.Forms.TextBox textbox in textboxes)
{
// the location on the form. you may need to play with this
// and it should change for each textbox
textbox.Location = new System.Drawing.Point(88, 50);
textbox.Name = "textbox"+cnt.ToString();
textbox.Size = new System.Drawing.Size(173, 20);
textbox.TabIndex = cnt;
textbox.Visible = true;
cnt++;
}
--------------
public partial class AGEP : IdealFramework.UI.Screen
{
TextBox[] TB1 = new TextBox[18];
public AGEP()
{
InitializeComponent();
}
private void AGEP_Load(object sender, EventArgs e)
{
int sub = 0;
int sub2 = 0;
while (sub < 18)
{
TB1[sub] = new TextBox();
sub2 = sub * 25 + 1;
TB1[0].Location = new Point(5, sub2);
pnlPmtArea.Container.Add(TB1[sub]);
sub++;
}
}
No comments:
Post a Comment