Hi,
In my application I have one file upload control. When the user selectes a file to upload and when he clicks on Attach button I need to show him the file name of the file he selected to upload and also show the Remove link button after the file name. In this case I need to generate link button dynamically.
I wrote a code like the following:
protected void btnAttach_ServerClick(object sender, EventArgs e)
{
string strFileName = MyFile.PostedFile.FileName;string c = System.IO.Path.GetFileName(strFileName);
listBoxAttachedFiles.Items.Add(c);
LinkButton b = new LinkButton();
b.Text = "Remove";
b.ID = "LB_" + b.Text;
b.Style.Add("display", "block");
listBoxLinks.Controls.Add(b);
//Panel1.Controls.Add(b);
}
With the above code it is showing only th file name in the listbox it is not showing the Remove button in the listboxlinks list box.
How to generate the link button and and write event when the remove is clicked i have to remove the corresponding file name from the other listbox.
Thanks in advance.
In my application I have one file upload control. When the user selectes a file to upload and when he clicks on Attach button I need to show him the file name of the file he selected to upload and also show the Remove link button after the file name. In this case I need to generate link button dynamically.
I wrote a code like the following:
protected void btnAttach_ServerClick(object sender, EventArgs e)
{
string strFileName = MyFile.PostedFile.FileName;string c = System.IO.Path.GetFileName(strFileName);
listBoxAttachedFiles.Items.Add(c);
LinkButton b = new LinkButton();
b.Text = "Remove";
b.ID = "LB_" + b.Text;
b.Style.Add("display", "block");
listBoxLinks.Controls.Add(b);
//Panel1.Controls.Add(b);
}
With the above code it is showing only th file name in the listbox it is not showing the Remove button in the listboxlinks list box.
How to generate the link button and and write event when the remove is clicked i have to remove the corresponding file name from the other listbox.
Thanks in advance.