UpdateProgress control-using icon-in uploadinf files

Reply Forum
Forum posttom @ 2009-04-29 09:58:36
ReplyReply to
hello there...your article is very simple and useful...thanks a lot :)

My point is that i want to keep the name of the file users upload like that:

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Width="134px"></asp:Label>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<input id="readFile" type="file" runat="server" size="35" />

</ContentTemplate>

</asp:UpdatePanel>

</div>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<img src="1.gif" alt="Loading"/>
Updating Page ......
</ProgressTemplate>
</asp:UpdateProgress>

the file name returns me Object reference not set to an instance of an object. But when i move <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> out of <ContentTemplate> then file name returns me the right name but then...the image doesn't appear.

The code i use to keep file's name(vb)-(it's ok) :

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

Dim test As String = ""
test = readFile.PostedFile.FileName

End Sub

thanks in advance



Forum postWebmaster @ 2009-04-29 22:48:19
ReplyReply to
Have you tried using the <asp:FileUpload> server control? That's what it's there for :)

Also, you might need to define the button as a trigger for the UpdatePanel, as described in this article: http://ajax.net-tutorials.com/controls/updatepanel-control/


Forum posttom @ 2009-04-30 09:33:03
ReplyReply to
thanks for your quick response!:)I follow your steps but nothing...

<form id="form1" runat="server" enctype="multipart/form-data" >
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div style="text-align: center">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" updatemode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>

<ContentTemplate>
<asp:Label ID="Label1" runat="server" Width="134px"></asp:Label><br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:FileUpload ID="FileUpload1" runat="server" />
</ContentTemplate>

</asp:UpdatePanel>

<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<img src="1.gif" alt="Loading"/>
Updating Page ......
</ProgressTemplate>
</asp:UpdateProgress>

</form>

Unfortunately the file name returns me again:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

Dim name As String = ""
name = FileUpload1.PostedFile.FileName

End Sub

"Object reference not set to an instance of an object"....

Any other ideas????



Forum postWebmaster @ 2009-04-30 20:18:32
ReplyReply to
Hi Tom,

After searching the web for a bit, this seems like a general problem, with the upload control not really working with an UpdatePanel. So far, there doesn't seem to be a solution, so I think you may have to do this another way.


Forum posttom @ 2009-05-04 09:09:22
ReplyReply to
Thanks...I've searched too...but how could i do this in another way???i'm stacked here......:(


Forum posttom @ 2009-05-06 10:42:08
ReplyReply to
hi again...i've found a solution -unfortunately it doesn't work for me...because i use master page,but i put here...maybe someone needs it

http://aspalliance.com/1442_Building_AJAX_Enabled_File_Uploading_System_with_Progress_Bar_Using_ASPNET_20.all

if you find something for me..plz let me know...











© net-tutorials.com 2006 - 2012

MailContact net-tutorials.com