473,668 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File Upload and CSS

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="multip art/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.PostedFi le.FileName
Dim strFileName As String
strFileName = Path.GetFileNam e(strFullPath)
'ViewState("str Directory") might by a folder like "db/" or "pdf/"
MyFile.PostedFi le.SaveAs(ViewS tate("strDirect ory") & 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 (HttpCacheabili ty.NoCache)
at the top of the page?

I appreciate any advice y'all can give.

Thanks,

Todd Acheson

Nov 19 '05 #1
8 5215
The "CSS is lost" ? Do you mean that tht resulting HTML code doesn't contain
any more a reference to your external sttylesheet ?

How is this stylesheet referenced from your APSX Page ?

Patrice


--

"Todd Acheson" <ta******@quest ared.com> a écrit dans le message de
news:13******** **************@ msnews.microsof t.com...
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="multip art/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.PostedFi le.FileName
Dim strFileName As String
strFileName = Path.GetFileNam e(strFullPath)
'ViewState("str Directory") might by a folder like "db/" or "pdf/"
MyFile.PostedFi le.SaveAs(ViewS tate("strDirect ory") & 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 (HttpCacheabili ty.NoCache)
at the top of the page?

I appreciate any advice y'all can give.

Thanks,

Todd Acheson

Nov 19 '05 #2
Oh, and another problem:

After the file is uploaded, if I have a link to this newly uploaded file,
and the user clicks on that link, they are prompted for WIndows Security
information (username, domain, and password).
But, if I publish that same file with FrontPage to the same directory that
it was uploaded, the user is longer prompted for security, and the link
works fine.

Any advice?

--
Todd Acheson

=============== =============== ==
"Todd Acheson" <ta******@quest ared.com> wrote in message
news:13******** **************@ msnews.microsof t.com...
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="multip art/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.PostedFi le.FileName
Dim strFileName As String
strFileName = Path.GetFileNam e(strFullPath)
'ViewState("str Directory") might by a folder like "db/" or "pdf/"
MyFile.PostedFi le.SaveAs(ViewS tate("strDirect ory") & 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 (HttpCacheabili ty.NoCache)
at the top of the page?

I appreciate any advice y'all can give.

Thanks,

Todd Acheson

Nov 19 '05 #3
Hello Patrice,

What I mean by "CSS is lost" is that the page has all the content for the
user, but the formatting supplied by the CSS is not being applied.

I reference the CSS by:

<link href="styles.cs s" type="text/css" rel="stylesheet ">

which is in the head of the html document.

-Todd
The "CSS is lost" ? Do you mean that tht resulting HTML code doesn't
contain any more a reference to your external sttylesheet ?

How is this stylesheet referenced from your APSX Page ?

Patrice

Nov 19 '05 #4
When it occurs have a look at the "show source" option in the browser to see
if the html code you send is correct (in particular do you have all always
the link tag ?). Note also that it looks like you are searching the css file
in the same location than your aspx page (is this intended ? What if you
replace the name of the page in the address bar with styles.css ? Can you
get the file ?)

Patrice

--

"Todd Acheson" <ta******@quest ared.com> a écrit dans le message de
news:13******** **************@ msnews.microsof t.com...
Hello Patrice,

What I mean by "CSS is lost" is that the page has all the content for the
user, but the formatting supplied by the CSS is not being applied.

I reference the CSS by:

<link href="styles.cs s" type="text/css" rel="stylesheet ">

which is in the head of the html document.

-Todd
The "CSS is lost" ? Do you mean that tht resulting HTML code doesn't
contain any more a reference to your external sttylesheet ?

How is this stylesheet referenced from your APSX Page ?

Patrice


Nov 19 '05 #5
Patrice,

I can still get the CSS file by typing it in the address bar.

When I look at the source of the page (View Source) in IE, the html for the
CSS link is missing!

Well now I know why the CSS is not being applied. The question becomes,
why?
-Todd

--
Todd Acheson

"Patrice" <no****@nowhere .com> wrote in message
news:ej******** ********@TK2MSF TNGP12.phx.gbl. ..
When it occurs have a look at the "show source" option in the browser to see if the html code you send is correct (in particular do you have all always
the link tag ?). Note also that it looks like you are searching the css file in the same location than your aspx page (is this intended ? What if you
replace the name of the page in the address bar with styles.css ? Can you
get the file ?)

Patrice

--

"Todd Acheson" <ta******@quest ared.com> a écrit dans le message de
news:13******** **************@ msnews.microsof t.com...
Hello Patrice,

What I mean by "CSS is lost" is that the page has all the content for the user, but the formatting supplied by the CSS is not being applied.

I reference the CSS by:

<link href="styles.cs s" type="text/css" rel="stylesheet ">

which is in the head of the html document.

-Todd
The "CSS is lost" ? Do you mean that tht resulting HTML code doesn't
contain any more a reference to your external sttylesheet ?

How is this stylesheet referenced from your APSX Page ?

Patrice



Nov 19 '05 #6
I fixed the problem of losing my CSS reference. The tag for the link to the
stylesheet is in a user control. The code for making the tag was within a
If Not Page.IsPostBack block of code. Removing this If statement fixed the
problem.

I'm still wondering why the users are prompted for Windows security when
clicking on a link to user uploaded files? Files published with FrontPage
don't have this problem.

My web.config has the authentication set to "none".

Todd Acheson
--
Todd Acheson

"Todd A" <ze**@olympus.c om> wrote in message
news:OG******** ********@TK2MSF TNGP09.phx.gbl. ..
Oh, and another problem:

After the file is uploaded, if I have a link to this newly uploaded file,
and the user clicks on that link, they are prompted for WIndows Security
information (username, domain, and password).
But, if I publish that same file with FrontPage to the same directory that
it was uploaded, the user is longer prompted for security, and the link
works fine.

Any advice?

--
Todd Acheson

=============== =============== ==
"Todd Acheson" <ta******@quest ared.com> wrote in message
news:13******** **************@ msnews.microsof t.com...
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="multip art/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.PostedFi le.FileName
Dim strFileName As String
strFileName = Path.GetFileNam e(strFullPath)
'ViewState("str Directory") might by a folder like "db/" or "pdf/"
MyFile.PostedFi le.SaveAs(ViewS tate("strDirect ory") & 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 (HttpCacheabili ty.NoCache)
at the top of the page?

I appreciate any advice y'all can give.

Thanks,

Todd Acheson


Nov 19 '05 #7
Check the permissions on the uploaded files and make sure read access is
allowed. I think the account that needs access is "IUSR_<machinen ame>" but I
might be wrong about that.

"Todd Acheson" wrote:
I fixed the problem of losing my CSS reference. The tag for the link to the
stylesheet is in a user control. The code for making the tag was within a
If Not Page.IsPostBack block of code. Removing this If statement fixed the
problem.

I'm still wondering why the users are prompted for Windows security when
clicking on a link to user uploaded files? Files published with FrontPage
don't have this problem.

My web.config has the authentication set to "none".

Todd Acheson
--
Todd Acheson

"Todd A" <ze**@olympus.c om> wrote in message
news:OG******** ********@TK2MSF TNGP09.phx.gbl. ..
Oh, and another problem:

After the file is uploaded, if I have a link to this newly uploaded file,
and the user clicks on that link, they are prompted for WIndows Security
information (username, domain, and password).
But, if I publish that same file with FrontPage to the same directory that
it was uploaded, the user is longer prompted for security, and the link
works fine.

Any advice?

--
Todd Acheson

=============== =============== ==
"Todd Acheson" <ta******@quest ared.com> wrote in message
news:13******** **************@ msnews.microsof t.com...
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="multip art/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.PostedFi le.FileName
Dim strFileName As String
strFileName = Path.GetFileNam e(strFullPath)
'ViewState("str Directory") might by a folder like "db/" or "pdf/"
MyFile.PostedFi le.SaveAs(ViewS tate("strDirect ory") & 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 (HttpCacheabili ty.NoCache)
at the top of the page?

I appreciate any advice y'all can give.

Thanks,

Todd Acheson



Nov 19 '05 #8
BW
Todd,

When they click on the link, they're basicly downloading the file right? I
think what you have to do is get the browser to display the download box
instead of trying to open the file. I'm not sure of the correct term for it
but you basicly stream the attachment. Something like this:

the file link calls the FileDownload.as px page like...: <a
href=FileDownlo ad.aspx?file=yo urFileWithFullP athAndExtension >File Name</a>

<%@ Import Namespace="Syst em.IO"%>
<script language="VB" runat="server">
Sub Page_Load(sende r As Object, e As EventArgs)

Dim filepath As String = Request.Params( "file")
If Not filepath Is Nothing Then
If File.Exists(fil epath) Then
Dim filename As String = Path.GetFileNam e(filepath)
Response.Clear( )
Response.Conten tType = "applicatio n/octet-stream"
Response.AddHea der("Content-Disposition", _
"attachment ; filename=""" & filename & """")
Response.Flush( )
Response.WriteF ile(filepath)
End If
End If

End Sub
</script>

This works fine for me. I hope this helps. re:
http://www.ondotnet.com/lpt/a/1354

Bernard

"Todd Acheson" <ta******@quest ared.com> wrote in message
news:ej******** ********@TK2MSF TNGP09.phx.gbl. ..
I fixed the problem of losing my CSS reference. The tag for the link to
the
stylesheet is in a user control. The code for making the tag was within a
If Not Page.IsPostBack block of code. Removing this If statement fixed
the
problem.

I'm still wondering why the users are prompted for Windows security when
clicking on a link to user uploaded files? Files published with FrontPage
don't have this problem.

My web.config has the authentication set to "none".

Todd Acheson
--
Todd Acheson

"Todd A" <ze**@olympus.c om> wrote in message
news:OG******** ********@TK2MSF TNGP09.phx.gbl. ..
Oh, and another problem:

After the file is uploaded, if I have a link to this newly uploaded file,
and the user clicks on that link, they are prompted for WIndows Security
information (username, domain, and password).
But, if I publish that same file with FrontPage to the same directory
that
it was uploaded, the user is longer prompted for security, and the link
works fine.

Any advice?

--
Todd Acheson

=============== =============== ==
"Todd Acheson" <ta******@quest ared.com> wrote in message
news:13******** **************@ msnews.microsof t.com...
> 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="multip art/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.PostedFi le.FileName
> Dim strFileName As String
> strFileName = Path.GetFileNam e(strFullPath)
> 'ViewState("str Directory") might by a folder like "db/" or "pdf/"
> MyFile.PostedFi le.SaveAs(ViewS tate("strDirect ory") & 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 (HttpCacheabili ty.NoCache)
> at the top of the page?
>
> I appreciate any advice y'all can give.
>
> Thanks,
>
> Todd Acheson
>



Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3728
by: Amy Kimber | last post by:
Hello all, ok, I have a file upload secton to my site, two pages, one with a form and one that does the uploading.... some files upload fine, other don't an exe of 300k will upload, but a word document of 40k wont and so on, in the php.ini a limit of 2mb is set (I haven't changed it, it's how the file originally as, so it isn't my maths that's gone mad).
15
3209
by: Simon | last post by:
I would like to create a very basic file upload add image form to add to my web site and to keep them in a "tmp" directory within my web hosting file manager once uploaded. I understand the basic html for the form and the basic php scripting but the fine details ie method post etc needs help also at this stage I dont want to involve mysql data base. were should I start.
3
2841
by: Bijoy Naick | last post by:
I've written a simple file upload user control in VB .NET. It comprises of an InputFile HTML Server Control, an Upload button and a message label. User clicks on the Browse button of the InputFile control, selects a file, then clicks on the Upload button. The file is saved to a folder on the server and the message label displays the appropriate msg. The user control also has a SetFilePath method.. This is used by the page which includes...
1
2753
by: BW | last post by:
I am creating an upload/download function for an extranet site. Files will be uploaded to directory based upon the users login and associated project. The function works as long as I use "c:\Temp" as the directory. When I use any other hard coded directory or even Server.MapPath() the upload function fails and returns the error: "Exception has been thrown by the target of an invocation." Once I change the root directory to "c:\Temp",...
6
3035
by: Vic Spainhower | last post by:
Hello, I am trying to do a FTP file upload which works fine on my localhost but on my ISP server it fails. I can't seem to find where I can go to find the specific cause of the failure. In both cases the file is being transmitted to the same FTP server and using the same PHP script so it shouldn't be a file size or login credentials problem. Could someone please help me out and give me some ideas what is wrong. I would really...
7
3184
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file" name="file_1" size=46 /><input type=submit /> so, after adding a few files, the input fields look like this:
2
7646
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but don't have any luck is to do a form validation. This script requires the files: db-file-to-disk.asp and _upload.asp. There is a DESCRIPTION field in the db-file-to-disk.asp file, what I want to do is the user has to field out this fied before...
3
613
by: shapper | last post by:
Hello, I need to upload a file. Can I only do this with the File Upload control? I also need the following: - Send upload info, upload percentage, continuously to a JavaScript function so I can display the Upload Progress.
12
2482
by: GuangXiN | last post by:
I want the file upload element disappear, instead of it, I place a text box and a button with my own css defination. but it doesn't work on IE7. What should I do now? <form action="upload.php" method="POST" enctype="multipart/form-data"> <p> <span>Select photo:</span> <input type="file" name="photo" style="display:none;"> <input type="text" name="photoUrl" class="s1" /> <input type="button" class="s2"...
0
2824
by: amskape | last post by:
hi Friends, I need to Upload some files in a Listing , by clicking corresponding Upload link, then a popup window will come with Browse option as Shown in attachment File. My actual need is upload files using that , but I can upload only 1 file there , I need to upload 1 to 5 files at a time based on need . How it can implement. I give my Working code here , in php Help me , if you know any other method to do same that's idea...
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8378
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8890
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8791
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8653
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4376
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1783
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.