From: Ray on
Hi All,

I am having problem to get the ID of fileupload control in as loop:

<form enctype="multipart/form-data" method="post" runat="server">
<asp:FileUpLoad id="FileName1" runat="server" />
<asp:FileUpLoad id="FileName2" runat="server" />
<asp:FileUpLoad id="FileName3" runat="server" />
</form>

Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
If Page.IsPostBack Then
Dim i As Integer
For i = 0 to Page.Controls.Count - 1
Response.Write(Page.Controls(i).ID & "<br>")
Next
Response.end()
End If
End Sub

this return empty, any help?

Thanks

Ray
From: Patrice on
Hello,

You should be able to access directly those fields using the FileName1,
FileName2,FileName3 variables created yor you...

For a better visibility put a breakpoint and/or print rather the type
(Page.Controls(i).GetType.ToString), you should have a control but as it has
non name...

The problem is likely that you are listed controls at the first level when
those controls are actually inside another control (declared by the form
tag).

--
Patrice


"Ray" <ray(a)newsgroup.com> a �crit dans le message de groupe de discussion :
Xns9D709FA32FBD2nospamnospamcom(a)207.46.248.16...
> Hi All,
>
> I am having problem to get the ID of fileupload control in as loop:
>
> <form enctype="multipart/form-data" method="post" runat="server">
> <asp:FileUpLoad id="FileName1" runat="server" />
> <asp:FileUpLoad id="FileName2" runat="server" />
> <asp:FileUpLoad id="FileName3" runat="server" />
> </form>
>
> Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
> Me.Load
> If Page.IsPostBack Then
> Dim i As Integer
> For i = 0 to Page.Controls.Count - 1
> Response.Write(Page.Controls(i).ID & "<br>")
> Next
> Response.end()
> End If
> End Sub
>
> this return empty, any help?
>
> Thanks
>
> Ray


From: ray on
In article <#tBxNCe7KHA.4508(a)TK2MSFTNGP06.phx.gbl>, "Patrice" says...
>
> Hello,
>
> You should be able to access directly those fields using the FileName1,
> FileName2,FileName3 variables created yor you...
>
> For a better visibility put a breakpoint and/or print rather the type
> (Page.Controls(i).GetType.ToString), you should have a control but as it has
> non name...
>
> The problem is likely that you are listed controls at the first level when
> those controls are actually inside another control (declared by the form
> tag).

Thank you Patrice,

But this is what I was look for:

Dim ctrl As Control
for each ctrl In Page.FindControl("form1").Controls
if ctrl.GetType() is GetType(FileUpload) then
Response.Write(ctrl.GetType.ToString & "<br>")
Response.Write(ctrl.ID.ToString & "<br>")
end if
next ctrl

Ray
From: Patrice on
This is not the code you posted...

Here try :
TypeOf ctrl is FileUpload

The difference is that you want to test if both types are the same actual
type not if those two object type are the same...

A quick sanity check would be to drop the test to make sure those controls
are listed...

--
Patrice


"ray" <ray(a)newsgroup.com> a �crit dans le message de groupe de discussion :
MPG.264de4c2998fbadf989680(a)news.microsoft.com...
> In article <#tBxNCe7KHA.4508(a)TK2MSFTNGP06.phx.gbl>, "Patrice" says...
>>
>> Hello,
>>
>> You should be able to access directly those fields using the FileName1,
>> FileName2,FileName3 variables created yor you...
>>
>> For a better visibility put a breakpoint and/or print rather the type
>> (Page.Controls(i).GetType.ToString), you should have a control but as it
>> has
>> non name...
>>
>> The problem is likely that you are listed controls at the first level
>> when
>> those controls are actually inside another control (declared by the form
>> tag).
>
> Thank you Patrice,
>
> But this is what I was look for:
>
> Dim ctrl As Control
> for each ctrl In Page.FindControl("form1").Controls
> if ctrl.GetType() is GetType(FileUpload) then
> Response.Write(ctrl.GetType.ToString & "<br>")
> Response.Write(ctrl.ID.ToString & "<br>")
> end if
> next ctrl
>
> Ray