.NETGURU
abt htmlinputfile ctrl
Messages   Related Types
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

Reply to this message...
 
    
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

Reply to this message...
 
    
Dot Net Guruhew 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.

--------------------------------
Dot Net Guruhew 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
Reply to this message...
 
 
System.Exception
System.IO.Path
System.Web.HttpContext
System.Web.HttpFileCollection
System.Web.HttpPostedFile
System.Web.UI.HtmlControls.HtmlInputFile
System.Web.UI.Page
System.Web.UI.UserControl
System.Web.UI.WebControls.ListBox
System.Web.UI.WebControls.TextBox
System.Windows.Forms.ListBox
System.Windows.Forms.TextBox
System.Windows.Forms.UserControl




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification