473,508 Members | 2,206 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to format fileupload control

111 New Member
How to format FileUpload control. As far as I am consurned there is no direct formating available for formating FileUpload Control using css.

I will share one of my ideas where I implemented this and working fine. I wanted to show the button in a formate which is common in an existing application and i had to create a new form where i need to use this fileupload control and I have to change the control look and feel so that it is not different from the existing one.

What I did is I took and image of the existing formated button and placed exactly at the fileupload button. And also changed the image when ever the user clicks so that it looks real. Please find the code below.


Html:
Expand|Select|Wrap|Line Numbers
  1. <link rel='StyleSheet' href="Styles/UploadButton.css" type='text/css'/>  
  2.  
  3.  <div class="fileinputs">
  4.         <asp:FileUpload type="file" ID="ctlFileUpload" runat="server" class="UploadButton" EnableTheming="true"/>
  5.         <div class="fakefile">
  6.            <img src="http://bytes.com/images/Browse.jpg" onclick="OpenFileUpload();" class="DirectUploadImage" alt="Select file to upload."
  7.             onmouseover="FileUploadHighlightOn(this);" onmouseout="FileUploadHighlightOff(this);" onmousedown="FileUploadClick(this);"/>
  8.         </div>
  9.     </div>
  10.  
  11.  
  12. <script type="text/javascript" language="Javascript">
  13.  
  14.   function OpenFileUpload() {
  15.             var ctlFileUpload = document.getElementById("ctlFileUpload");
  16.             ctlFileUpload.click(); 
  17.         }    
  18.  
  19.  
  20.  
  21.  
  22. //These functions are used to change the image when the user points on the image.
  23. function FileUploadHighlightOn(element)
  24.     {
  25.          element.src = "http://bytes.com/images/BrowseOver.jpg";
  26.     }
  27.  
  28.     function FileUploadHighlightOff(element)
  29.     {
  30.         element.src = "http://bytes.com/images/Browse.jpg";
  31.     }
  32.  
  33.     function FileUploadClick(element) {
  34.         element.src = "http://bytes.com/images/BrowseClick.jpg";
  35.     }   
  36.  
  37. </script>
  38.  
UploadButton.css
Expand|Select|Wrap|Line Numbers
  1. .UploadButton
  2. {   font-size: 8pt;    
  3.     font-family: Arial;  
  4.     }
  5.  
  6. div.fileinputs {
  7.     position: relative;
  8. }
  9.  
  10. div.fakefile {
  11.     position: absolute;
  12.     top: 0px;
  13.     left: 132px;
  14.     z-index: 1;
  15. }
  16.  
  17. input.file {
  18.     position: relative;
  19.     text-align: right;
  20.     -moz-opacity:0 ;
  21.     filter:alpha(opacity: 0);
  22.     opacity: 0;
  23.     z-index: 2;
  24. }
  25.  
I used different images for the image button, onmouseover, out and click. So that it appears live for the user, and not like an image.

Thanks
Bharath Reddy vasiReddy
Mar 22 '10 #1
0 15217

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2917
by: Islamegy® | last post by:
I'm use FormView for editing a photo gallery... I add FileUpload control to upload images to the Gallery. I'm binding my Formview to objectdatasource i tried upload images onItemInserting &...
1
7027
by: Marko Vuksanovic | last post by:
I am trying to implement an upload progress indicator using atlas, using the following workaround: http://forums.asp.net/thread/1321664.aspx This is the code in FileUpload.apsx file is as...
12
15626
by: Phil Z. | last post by:
After migrating an ASP.NET 1.1 application to 2.0 we were getting "Cannot access a closed file" errors when uploading. I found a number of post on the subject and have since moved from using an...
4
5660
by: Dave | last post by:
If you had a FileUpload control inside of a FormView...how would you use FindControl to access the FileUpload properties? Let me just say that...
1
3254
by: Harinath | last post by:
Hi All, I am working on a portal using .net2.0. In one of my page, i have FileUpload control. I am doing some server side validation for form fields in general. if there is any validation...
3
5153
by: rn5a | last post by:
The ASPX FileUpload control displays a TextBox along with a 'Browse...' Button. Setting the different properties of this control just reflects the changes in the TextBox but not the Button. For...
1
1963
by: Nathan Sokalski | last post by:
I have an ASP.NET 2.0 webform which includes both a FileUpload contol and a Calendar control. When the user selects a new data with the Calendar control, the FileUpload control is reset (there is...
5
12075
by: =?Utf-8?B?QmVydA==?= | last post by:
Hi How can you set the filename property in the asp:fileupload control? How can you persist the value of the chosen filename between postbacks? thanks B
9
9716
by: vital | last post by:
Hi, I have a User control which has a fileupload control. With the requirements I placed the user control in a UpdatePanel of ASP.NET Ajax and the fileupload.postedfile.filename giving error. ...
2
5975
by: =?Utf-8?B?UGF1bA==?= | last post by:
I have a gridview with 2 columns. One column is a BoundColumn to a part number (string). One column is an ItemTemplate with a FileUpload control. There can be multiple rows (i.e. part numbers)...
0
7225
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,...
0
7123
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...
0
7498
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...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
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...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
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...

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.