Mani se Request.Form-a. Ovo hoćeš:
WebForm1.aspx.cs:
Code:
using System;
using System.Collections;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebApplication1
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.ImageButton ImageButton1;
protected System.Web.UI.WebControls.PlaceHolder PlaceHolder1;
protected System.Web.UI.WebControls.Label Label1;
protected ArrayList al = new ArrayList();
private void Page_Load(object sender, System.EventArgs e)
{
if (IsPostBack)
{
for (int i = 0; i < 10; i++)
{
if (al[i] is TextBox)
Label1.Text += ((TextBox)al[i]).Text;
}
}
}
private void Page_Init(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
for (int i = 0; i < 10; i++)
{
TextBox tb = new TextBox();
tb.ID = "tb" + i.ToString();
al.Add(tb);
PlaceHolder1.Controls.Add(tb);
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.Init += new System.EventHandler(this.Page_Init);
}
#endregion
}
}
WebForm1.aspx:
Code:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:ImageButton id="ImageButton1" runat="server"
ImageUrl="jimihendrix.gif">
</asp:ImageButton>
<asp:PlaceHolder id="PlaceHolder1" runat="server">
</asp:PlaceHolder>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</form>
</body>
</HTML>