T
Todd Acheson
I'm having a small problem with uploading files in ASP.NET.
My html page for uploading has something similar to:
<form id="Form1" method="post" enctype="multipart/form-data" runat="server">
<input id="MyFile" type="file" runat="server" size="50">
<asp:Button Runat="server" ID="btnUpload" Text="UPLOAD" />
</form>
.. . .and the corresponding vb.net code:
Dim strFullPath As String
strFullPath = MyFile.PostedFile.FileName
Dim strFileName As String
strFileName = Path.GetFileName(strFullPath)
'ViewState("strDirectory") might by a folder like "db/" or "pdf/"
MyFile.PostedFile.SaveAs(ViewState("strDirectory") & strFileName)
All very straighforward stuff that we've all used before.
A file will upload just fine with the above code. The problem is, that when
the page comes back to the browser, all the CSS is lost. This is true in
both IE6 and FireFox 1.0. The design of the page(s) is a TableLess design
(no html tables). I have other projects where this worked fine, and the
CSS wasn't lost, but the upload was in an html table. Since it happens in
both of these browsers, I'm thinking it isn't browser dependent??
My question is: Is there something wrong with the above code that is triggering
the CSS to be lost? Is it a bug in ASP.NET?
As a solution, I could probably redirect the user to a different page indicating
the results of their attempted file upload.
Maybe I could try setting using:
Response.Cache.SetCacheability(HttpCacheability.NoCache)
at the top of the page?
I appreciate any advice y'all can give.
Thanks,
Todd Acheson
My html page for uploading has something similar to:
<form id="Form1" method="post" enctype="multipart/form-data" runat="server">
<input id="MyFile" type="file" runat="server" size="50">
<asp:Button Runat="server" ID="btnUpload" Text="UPLOAD" />
</form>
.. . .and the corresponding vb.net code:
Dim strFullPath As String
strFullPath = MyFile.PostedFile.FileName
Dim strFileName As String
strFileName = Path.GetFileName(strFullPath)
'ViewState("strDirectory") might by a folder like "db/" or "pdf/"
MyFile.PostedFile.SaveAs(ViewState("strDirectory") & strFileName)
All very straighforward stuff that we've all used before.
A file will upload just fine with the above code. The problem is, that when
the page comes back to the browser, all the CSS is lost. This is true in
both IE6 and FireFox 1.0. The design of the page(s) is a TableLess design
(no html tables). I have other projects where this worked fine, and the
CSS wasn't lost, but the upload was in an html table. Since it happens in
both of these browsers, I'm thinking it isn't browser dependent??
My question is: Is there something wrong with the above code that is triggering
the CSS to be lost? Is it a bug in ASP.NET?
As a solution, I could probably redirect the user to a different page indicating
the results of their attempted file upload.
Maybe I could try setting using:
Response.Cache.SetCacheability(HttpCacheability.NoCache)
at the top of the page?
I appreciate any advice y'all can give.
Thanks,
Todd Acheson