Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: C# -- Exiting out of an iteration of a foreach loop?


Message #1 by "Oliver, Wells" <WOliver@l...> on Tue, 29 Oct 2002 10:17:39 -0800
Trying to do:

			foreach (System.Web.UI.Control objControl in
e.Item.Controls)
			{
				if (objControl.GetType().ToString() ==
"System.Web.UI.HtmlControls.HtmlInputFile")
				{
					objFile 
((HtmlInputFile)objControl);
					if
(objFile.PostedFile.FileName.ToString() == "")
						return;
					strSavePath 
Request.ApplicationPath +
System.Configuration.ConfigurationSettings.AppSettings["savePath"];
					strSavePath +=  strClass + "/" +
objFile.ID.ToString() + "/" + getFileValue(objFile);
					objFile.PostedFile.SaveAs
(Request.MapPath (strSavePath));
				}
			}

That doesn't seem to be the proper way to exit out of an iteration of a
foreach loop. Any tips?

Wells Oliver
Web Applications Programmer
Leviton Voice & Data
xxx-xxx-xxxx
http://www.levitonvoicedata.com 

Message #2 by "Christopher Reed" <CReed@m...> on Wed, 30 Oct 2002 09:45:34 -0600
Wells,

Try using "break".

Hope this helps!

Christopher Reed
Application Analyst
Web Development Coordinator
Information Technology
City of Lubbock
creed@m...
"The oxen are slow, but the earth is patient."

>>> WOliver@l... 12:17:39 PM 10/29/2002 >>>
Trying to do:

			foreach (System.Web.UI.Control objControl in
e.Item.Controls)
			{
				if (objControl.GetType().ToString() ==
"System.Web.UI.HtmlControls.HtmlInputFile")
				{
					objFile 
((HtmlInputFile)objControl);
					if
(objFile.PostedFile.FileName.ToString() == "")
						return;
					strSavePath 
Request.ApplicationPath +
System.Configuration.ConfigurationSettings.AppSettings["savePath"];
					strSavePath +=  strClass + "/"
+
objFile.ID.ToString() + "/" + getFileValue(objFile);
					objFile.PostedFile.SaveAs
(Request.MapPath (strSavePath));
				}
			}

That doesn't seem to be the proper way to exit out of an iteration of
a
foreach loop. Any tips?

Wells Oliver
Web Applications Programmer
Leviton Voice & Data
xxx-xxx-xxxx
http://www.levitonvoicedata.com 

  Return to Index