asp.net dynamic creation problem.

Joined
Sep 24, 2009
Messages
4
Reaction score
0
Good Day,

I am a recent graduate asp.net website developer. The question i have is in regards to dynamically generating some controls depending on input. My code is below:

//FRONT END
<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeFile="NuggetImages.aspx.cs" Inherits="Admin_NuggetImages" Theme="Admin"%>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div><h1>Nugget Main Page Images</h1></div>
<asp:placeHolder ID="PlaceHolderUpFiles" runat="server">
</asp:placeHolder>
</asp:Content>

//BACK END
public partial class Admin_NuggetImages : System.Web.UI.Page
{
//number if image uploads to display
private int iImages = 0;
//connection string
private SqlConnection myCon = new SqlConnection("Data Source=(local)\\SQLEXPRESS;Initial Catalog=Nugget;Integrated Security=True");
//initialize file upload depending on the number passed in
private FileUpload[] myUpFiles;

protected void Page_Load(object sender, EventArgs e)
{
//retreiving the number of file uploads to display
iImages = Convert.ToInt32(Request.QueryString["iImages"]);
myUpFiles = new FileUpload[iImages];
//setting the ID's for access of the dynamically created controls!
for (int i = 0; i < iImages; i++)
{
myUpFiles = new FileUpload();
myUpFiles.ID = "imageUpload" + i.ToString();
}
CreateUploads();
}

protected void CreateUploads()
{
Response.Write("<table>");
for (int i = 0; i < iImages; i++)
{
Response.Write("<tr><td>");
Response.Write("hi");
PlaceHolderUpFiles.Controls.Add(myUpFiles);
Response.Write("</td></tr>");
}
PlaceHolderUpFiles.Visible = true;
Response.Write("</table>");
}
}

//QUESTION
How do I Response.Write into the place holder. Currently the response.write shows up top left corner of the page, i would like to format the controls into a table, right now they are in a line. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top