Help On Adding Upload Control Dynamically

Posted by Vijayar under C# on 2/17/2012 | Points: 10 | Views : 1589 | Status : [Member] | Replies : 3
Hi
I am placing a upload control.When i click on add button another upload control should be displayed.And insert the files in to a file in 3 tier,How to do this
The table fields are id and photoname

vijaya


Responses

Posted by: Pradeepkumar417 on: 2/17/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

You can add file upload control dynamically like below.

 protected void btnaddUpload_Click(object sender, EventArgs e)

{
form1.Controls.Add(AddUpload("File"));
}
private FileUpload AddUpload(string id)
{
FileUpload b = new FileUpload();

b.ID = id;

return b;
}


Thanks & Regards,
Software Engineer,
Pradeep Kumar

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vijayar on: 2/17/2012 [Member] Starter | Points: 25

Up
0
Down
I need along with delete button also,by the side of it

vijaya

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pradeepkumar417 on: 2/17/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

Along with delete button

 protected void btnaddUpload_Click(object sender, EventArgs e)

{
form1.Controls.Add(AddUpload("File"));
form1.Controls.Add(AddButton("btndelete","Delete"));
}
private FileUpload AddUpload(string id)
{
FileUpload b = new FileUpload();

b.ID = id;

return b;
}
private Button AddButton(string id, string name)
{
Button b = new Button();
b.Text = name;
b.ID = id;
b.Click += new EventHandler(Button_Click);
b.OnClientClick = "ButtonClick('" + b.ClientID + "')";
return b;
}
protected void Button_Click(object sender, EventArgs e)
{
Control ctr = new Control();
ctr.ID = "File";
form1.Controls.Remove(ctr);

}


Thanks & Regards,
Software Engineer,
Pradeep Kumar

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response