In this blog series, you have assumed that everything has gone correctly when uploading files. However, if you attempt to upload a file that is too large, you receive an error from your web server. In this blog post you are going to learn how to get the maximum size of file allowed, display that value on the page, handle an error when the file is too large, and modify the maximum size of file allowed. If you have not done so already, please download the sample from Part 5 so you can follow along with this blog post.
So far in this blog post series on uploading files with MVC, you have learned to style the file upload control, use a view model for data binding, create a thumbnail from an uploaded image, and store files on the server's file system. In this post, you learn to store the uploaded file in an SQL Server table. If you have not done so already, please download the sample from Part 4 so you can follow along with this blog post.
You may not know, but two principals at Fairway Technologies are published authors at Pluralsight.com. Pluralsight is the leader in online technology courses. Paul D. Sheriff and Michael Krasowski have created over 20 courses covering topics from Project Management, Estimation to WPF, MVC and Angular. Check out the complete list of the courses produced to date.
When a user clicks on a button on a web page, there can be a delay between posting back to the server and the next action that happens on the screen. The problem with this delay is the user may not know they actually clicked on the button and tries to hit the button again. It is important to give immediate feedback to the user so they know that the application is doing something. This post will show you how to disable the button, display a pop-up message and gray out the background before the post back happens thereby providing feedback to our user.
At my last company, I was working on moving a legacy ASP.NET WebForms application to MVC3. During the migration process, we had to implement some features in our legacy ASP.NET WebForms app (y’know, to stay competitive and stuff). Our WebForms guy did some fairly slick UI work – he leveraged the Telerik controls we purchased to create some dropdown lists that had icons next to each item in the list.
During one of our standups, my manager asked “Jeff, you’re working in an area related to [feature x], right?”
“Yeah…” I replied sheepishly, knowing what was coming next.
“Do you think you could make the dropdown list on your MVC screen look like the existing WebForms screen?”
Without really thinking, I replied with my de facto silly answer: “I’m a programmer – I can do anything! I’ll look into it and see what I can find.”
Before continuing any further, I’d like to throw out a word of caution: “I can do anything” is the worst possible answer a developer can give. Period. I’d even go so far as to say that “I can do anything” is the worst possible combination and sequence of words in the English language. Your manager/product manager/in-charge person will most likely take you seriously, regardless of your tone. If you find that infernal phrase on the tip of your tongue, take a deep breath and count to 10. Then say something else. Please learn from my mistake and consider yourself warned.
But I digress.
So, off to the Google-net I went.