Customize AsyncFileUpload (MS ajax control toolkit ), cross browser too
- Download FileUploaderAjax40 - 1.06 MB (VS2010 + .NET 4.0)
- Download FileUploaderAjax35 - 1.05 MB (VS2005 + .NET 3.5)
Introduction
This article is about how to customize the look and feel of AsyncFileUpload from MS ajax control toolkit. Source code for both VS 2010 and VS 2005 is available. A live demo is also available for you the see how it runs.
Background
Ajax control toolkit is a Microsoft open source project. Among the toolkit, there is a very useful control called “AsyncFileUpload”. You can see Ms official demo of this control here.
It's powerful but hard to customize from its built-in properties.
I successfully customized it through two approaches. You can see my live demo here
Using the code
After extracted source code, you can directly open the solution file (one for VS2010 the other for VS2005 just in case).
To keep it simple, they are both edited under "web site" project not "web application". You can directly run them by clicking "run" from IDE.
NOTE: VS2010 project needs .NET 4.0 installed locally for debugging. VS2005 project needs .NET 3.5 installed locally for debugging
Points of Interest
The basic idea of customizing AsyncFileUploader is using mask trick:
You make the AsyncFileUploader transparent and have a button or image looks covered AsyncFileUploader. But actually, the AsyncFileUploader is on top of masked button/image. So the user seems to click the masked customized button/image, but actually clicks the AsyncFileUploader.
That's just basic idea. I implement it in two approaches.
Approach 1 is easy and quick. Basically you make a customized button with similar size of AsyncFileUploader. The limitation of this approach is you can not make big button because the size of AsyncFileUploader itself is hard to adjust (especially the height if it's even possible)
Approach 2, Allow me to be proud for myself: The idea is that you can not adjust AsyncFileUploader size easily, but you can move it. So I move it inside of the big image button. Whenever user clicks, the AsyncFileUploader gets clicked.
To make it more clear, I have a X/Y position box to show you the mouse position when it's in the image scope. If you really want to see how the internal control moving, you can change the transparent value of the control. (it's 0 to be totally transparent, you can change it to 50 as half transparent)
Things to be aware of
I didn’t find a good way to gracefully catch the the over size uploading issue. I tried global.asax application error catching, also tried AsyncFileUpload built-in error catching. It seems global.asax can catch the specific error, but can not throw it gracefully. So I end up using warning UI and <httpRuntime maxRequestLength="500"/> from web.config. It’s not perfect but works for all major browsers.
Another thing to be aware of: The solution also works under latest IE9 RC, but you have to run it under IE8 compatible mode.
SUMMARY
All codes are tested under major browsers: IE8/IE9 RC/Firefox 3.6/Chrome 9. It's nice to have such a built-in control to work with.
Hope this is helpful to your projects as well.
History
No history yet
Post Comment
g7Lp5G Im grateful for the article.Really looking forward to read more. Great.
EnosY1 This is a topic which is close to my heart Take care! Exactly where are your contact details though?
35Ns51 This excellent website definitely has all the information and facts I needed abo
9APojC Generally I do not read article on blogs, but I wish to say that this write-up very compelled me to try and do it! Your writing style has been surprised me. Thank you, very nice article.
I really liked your post.Really thank you! Keep writing.
Im obliged for the blog post.Much thanks again. Cool.
Looking forward to reading more. Great blog.Much thanks again. Awesome.
I think this is a real great article post.Really looking forward to read more. Want more.
Really informative blog article.Thanks Again. Much obliged.
Hey, thanks for the blog article.Really thank you! Keep writing.
I really enjoy the article.Really looking forward to read more. Want more.
This is one awesome article post.Thanks Again. Want more.
Thanks a lot for the blog. Awesome.
Very neat blog post.Thanks Again. Really Cool.
Thanks a lot for the blog post.Really looking forward to read more. Much obliged.
Thanks so much for the blog article.Really looking forward to read more. Fantastic.
Great, thanks for sharing this blog.Thanks Again. Awesome.
Thank you ever so for you blog.Really thank you! Great.
Enjoyed every bit of your article.Really looking forward to read more. Much obliged.
Thanks so much for the blog article.Really looking forward to read more. Great.
Awesome article post.Really looking forward to read more. Fantastic.
I truly appreciate this article post.Really thank you! Want more.
A big thank you for your post.Much thanks again.
A round of applause for your article post.Really looking forward to read more. Awesome.
Enjoyed every bit of your blog post.Thanks Again. Really Great.
I think this is a real great blog article.Really looking forward to read more. Fantastic.
Thanks a lot for the blog.Thanks Again. Keep writing.
Very good blog post.Really looking forward to read more. Cool.
I am so grateful for your article.Much thanks again. Will read on...
Thanks-a-mundo for the article.Really thank you! Awesome.
Im grateful for the blog article.Thanks Again. Much obliged.
wow, awesome blog post.Thanks Again. Really Cool.
I really enjoy the article.Really looking forward to read more. Really Cool.
Really informative article.Really looking forward to read more. Awesome.
Really appreciate you sharing this blog.Thanks Again. Cool.
Very informative post.Much thanks again. Really Great.
This is one awesome blog.Much thanks again. Much obliged.
wow, awesome blog.Thanks Again. Really Cool.
I really liked your blog post. Really Cool.
Major thankies for the post.Thanks Again. Really Cool.
Very good blog post.Thanks Again. Want more.
Really informative blog article.Much thanks again. Much obliged.
Thanks so much for the blog article.Thanks Again. Much obliged.
I loved your post.Thanks Again. Keep writing.
Really appreciate you sharing this blog.Thanks Again. Really Great.
Im thankful for the article post.Thanks Again. Awesome.
I really liked your post.Thanks Again. Really Cool.
Im thankful for the article post.Thanks Again. Great.
This is one awesome post. Keep writing.
Really enjoyed this article post.Really looking forward to read more. Keep writing.