Link to home
Start Free TrialLog in
Avatar of coastman14

asked on

c# syntax Loop through request.files Item...

                                                 foreach (string item in Request.Files)
                  if (System.Web.UI.WebControls.[item].PostedFile.ContentLength <= 250000)
                                                                                                                   The type or namespace name 'item' does not exist in the class or namespace 'System.Web.UI.WebControls' (are you missing an assembly reference?)

 I am creating the Files in a placeholder and they do not have static names, what syntax do i use, for the simple example above...

Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

maybe you can post where item is declared
Hi, you have a period before the indexer, try changing your condition to:

if (System.Web.UI.WebControls[item].PostedFile.ContentLength <= 250000)
Sorry ignore my previous post, it wouldn't correct the issue
Avatar of coastman14


     private void cmdUpload_ServerClick(object sender, System.EventArgs e)
                  string filenumber="";
                  string formvalue="";
                  string mysql=" update lee2 set ";
                  //foreach ( DataRow row in table.Rows )
                  foreach (string item in Request.Files)
                  //Go and get the files that are not null
                  if (( Request.Files[item] != null) && (Request.Files[item].ContentLength>0))
                  string sFileName = System.IO.Path.GetFileName(Request.Files[item].FileName);
                  //Response.Write (sFileName);
                  //Response.Write (item.ToString());            
                  formvalue=(Request.Form["textbox" + filenumber]);
                        if (formvalue!="" && formvalue!=" " && formvalue!=null && Request.Form["textbox" + filenumber]!="" && System.Web.UI.WebControls.[item].PostedFile.ContentLength <= 250000)
In fact Zephyr's comment is interesting, there is a strage dot after WebControls...
Avatar of Ravi Singh
Ravi Singh
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial