473,549 Members | 2,568 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.cs s
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 15250

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

Similar topics

2
2923
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 & onItemUpdating but no luck.. FindControl() didn't work and can't find my fileUpload control.. any help plzzzzzzzzzz?? I just upgraded to .net 2 and...
1
7031
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 follows: <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title> drag </title> </head> <body> <form id="f1"...
12
15646
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 Html File Input control to using the new FileUpload control. Previously, I had set the maxRequestLength attribute in the machine.config file to...
4
5664
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 (FileUpload)FormView1.FindControl(FileUpload1).FileName doesn't work. The purpose is to insert a graphic in the InsertItemTemplate section of the form. I'm using the expample that's in the online...
1
3256
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 missing control comes back to the user. All other fields in the screens are retaining their values, but the
3
5162
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 e.g. if the BackColor of a FileUpload control is set to blue, then only the TextBox color changes to blue but the BackColor of the Button doesn't...
1
1964
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 no longer a file selected if one was previously selected). I am assuming this is because the Calendar control causes a postback when a date 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
9722
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. I read some articles that Ajax is not compatible with fileupload. I want to know the solution or workaround for this. Thanks
2
5979
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) in the gridview. The user attaches a file for each part number / row. The user clicks a button after attaching all the needed files.
0
7459
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...
0
7726
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. ...
0
7819
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...
0
6052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5097
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3505
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...
1
1953
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 we have to send another system
1
1064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
772
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...

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.