I have been working on this for over 20 hours, and it says to refresh the dynamic TextBox with its Id from Page_Init.
well it would need to be from Page_Load in my case as I need to access an Image and TextBox to add to my dynamic object.
If it can be done in my case then can you please spoon feed me as it seems so complicated to me.
My main code to add the dynamic object made up from an image and TextBox is given below.
protected void DisplayUserFiles(string Message)
{
using (var DB = new ServicingDB())
{
Panel5.Controls.Clear();
var variable = "~/Fire Door Pdfs/" + "Gary";
var folder = HttpContext.Current.Server.MapPath(variable);
System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(Server.MapPath("~/Fire Door Pdfs/" + "Gary"));
FileInfo[] listfiles = dirInfo.GetFiles("*.jpg*");
if (listfiles.Length > 0)
{
foreach (FileInfo file in listfiles)
{
var FileName = file.Name;
Panel Panel = new Panel();
Panel.Width = 150;
Panel.Height = 200;
HtmlImage img = new HtmlImage();
img.Height = 100;
TextBox Text = new TextBox();
Text.ID = "txtDynamic" + Guid.NewGuid().ToString();
if (FileName.Contains(".jpg"))
{
img.Src = "~/Fire Door Pdfs/" + "Gary" + "/" + FileName;
}
// Add Image
Panel.Controls.Add(img);
Panel.Controls.Add(new LiteralControl("<br />"));
// Add TextBox
Panel.Controls.Add(Text);
Panel.Controls.Add(new LiteralControl("<br />"));
// Add Panel with its related controls
Panel5.Controls.Add(Panel);
}
}
}
}