How to Get all the Dynamically created controls ?
-
I have developed a web app where i am creating dynamic Input Type File controls for selecting multiple files at a time. All the dynamically created Input controls are placed under one div 'myDiv'. Now while postback, how can i iterate through all the controls inside myDiv so that I can get hold of all the files selected during that time. Please help. Thanks in advance.
Sekhar :)
-
I have developed a web app where i am creating dynamic Input Type File controls for selecting multiple files at a time. All the dynamically created Input controls are placed under one div 'myDiv'. Now while postback, how can i iterate through all the controls inside myDiv so that I can get hold of all the files selected during that time. Please help. Thanks in advance.
Sekhar :)
Well, if you didn't create them prior to Page_Load, the fact is, they are not going to have any viewstate, even if you recreate them. But, if they are input controls, then they will exist in the form that was posted, so that's not a problem. The div is irrelevant, the file data will exist in the data posted with the form.
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
-
Well, if you didn't create them prior to Page_Load, the fact is, they are not going to have any viewstate, even if you recreate them. But, if they are input controls, then they will exist in the form that was posted, so that's not a problem. The div is irrelevant, the file data will exist in the data posted with the form.
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
-
Thanks for your reply. Can you please say me how can I reference to the form that has been posted back. I am an new to ASP.Net. Please help. Thanks.
Sekhar :)
Page.Request.Form.AllKeys gives you a collection of strings, each of which is a key into the collection as in Page.Request.Form["key"], you can use this to iterate through the form objects.
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
-
I have developed a web app where i am creating dynamic Input Type File controls for selecting multiple files at a time. All the dynamically created Input controls are placed under one div 'myDiv'. Now while postback, how can i iterate through all the controls inside myDiv so that I can get hold of all the files selected during that time. Please help. Thanks in advance.
Sekhar :)
SekharOne wrote:
are placed under one div 'myDiv'
ASP.NET won't maintain viewstate for Dynamic controls created in page_load. You can add these controls to a DataGrid/GridView than to a DIV. So viewstate will be maintained along with the parent control and you can take the control by iterating through gridview's rows.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions