This message was discovered on ASPFriends.com 'aspngbeta' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| Sampada Khare |
Scenario: I have HtmlInputFile ctrls File_1 to File_5 In the Button_Click method with Script language as VB and runat =server i have to upload the files. I want to loop through these controls and want to access the properties and methods of the htmlinputfile objects.. How do i go about this ?
Is there any method like there was "eval" in javascript ??
Thanks Sampada
|
|
| |
| |
| Michael Gaertner (VIP) |
Maybe this will help. The following code runs through text box controls on an aspx page and fills them with data from SQL:
/* Find the ContentPane TD tag, access Control zero * which will be this control, cast appropriately, * and run though all the controls inside the 'container' * (i.e., TextBox, ListBox, Label). * To check if control is a web control textbox, * attempt cast via as keyword. TextBox IDs match * DB fields. Load the value. */
UserControl container = (UserControl)Page.FindControl("ContentPane").Controls[0];
foreach ( Control ct in container.Controls ) { TextBox t = ct as TextBox; if ( t != null ) t.Text = rc[0][t.ID].ToString(); }
Sorry it's C#. I don't know if there's an eval keyword, but I doubt it.
Good luck.
Michael -----Original Message----- From: Sampada Khare [mailto:Click here to reveal e-mail address] Sent: Thursday, May 10, 2001 12:31 AM To: aspngbeta Subject: [aspngbeta] abt htmlinputfile ctrl
Scenario: I have HtmlInputFile ctrls File_1 to File_5 In the Button_Click method with Script language as VB and runat =server i have to upload the files. I want to loop through these controls and want to access the properties and methods of the htmlinputfile objects.. How do i go about this ?
Is there any method like there was "eval" in javascript ??
Thanks Sampada
| [aspngbeta] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngbeta.asp = JOIN/QUIT
|
|
| |
| |
| Matthew Carter |
Hi,
I've done this before in VB (by accident) and never thought it'd come in handy, so here you go:
'' First grab the posted file collection from request Dim _files As System.Web.HttpFileCollection = System.Web.HttpContext.Current.Request.Files
Try Dim _iFile As Integer = 0 uData.WordCount = 0
''' now loop through them For _iFile = 0 To (_files.Count - 1)
'' Access the individual posted file Dim _postedFile As System.Web.HttpPostedFile = _files(_iFile)
'' Now we can fiddle around with it Dim _fileName As String = System.IO.Path.GetFileName(_postedFile.FileName) Dim _fileExtension As String = System.IO.Path.GetExtension(_fileName) Next Catch ex as System.Exception Me.Response.Write(ex.ToString) End Try
Hope this helps.
-------------------------------- Matthew Carter
Lead Developer
+44 (0) 870 990 5166
http://www.appliedlanguage.com/
Translation services for 140 different languages
http://www.appliedlanguage.com/website_translation.shtml
Website translations for all file types, formats and technology
|
|
| |
|
|
|
|
|
|