Home

Thursday, February 24, 2011

File Upload not Working on First PostBack after loading Async through ASP.NET UpdatePanel

I was setting up a ASP.NET Wizard control.  The 3rd or 4th step had a file upload control on it, with a runat="server".  The entire wizard control I wrapped in an ASP.NET UpdatePanel so that the wizard was all AJAXified.  I had already fixed the "next" button for this wizard step so that it did a full postback to the server, not an asynchronous one - since I knew that was required to get a file upload to the server.  However, the file was STILL not being posted back, atleast not on the first post.  Subsequent posts would work fine.  On a whim, I looked at the Firebug console to inspect the details of the request while it was in progress (Set a breakpoint in your code somewhere, then look at the Firebug console -- you'll see a "POST" entry with info about what was posted, headers for the request, etc).  Below the POST entry, I saw a warning/error message I had never seen before:
 This page has a file upload.  However, the form tag does not have both the enctype=multipart/form-data and method=POST attributes.  The file will not be uploaded.
Hmm...  I thought about it a bit, and then looked at a normal page I had that had file upload controls on it.  Sure enough, the form tag (there is always just one in ASP.NET) had the enctype attribute set automagically by ASP.NET if ASP.NET knew there was a file upload control on the page.  Otherwise, it leaves it off.  The Async update by the UpdatePanel was loading the FileUpload ok, but wasn't adding the enctype=multipart/form-data to the form tag attributes. 
Solution: manually add the enctype to the page's form on Page_Load()

                                                             
 Page.Form.Attributes.Add("enctype", "multipart/form-data"); 
                                                             

Source: http://blog.anofsinger.com/

Monday, February 21, 2011

ASP.NET Tip: Creating Paging for a Repeater Control

There are many ways to page data in a DataList control or Repeater control in ASP.NET. But I think the following solution is the easiest way to create a custom paging when working with a DataList or a Repeater control. You can modify to have the "Next" and "Previous" button as well as styling the current page number easily. This article is from http://itmanagement.earthweb.com and I hope it will help you sometimes!

A common question is "How do I implement paging within a Repeater?" Although the beauty of the Repeater control is its flexibility, you're on your own for building most functions. ASP.NET 2.0 has included some new controls that provide paging, as does the DataGrid in ASP.NET 1.1. However, this tip shows you how to roll your own paging for a simple data viewer.
Here's the code behind for the page this tip builds:
using System;
using System.Data;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

Monday, February 14, 2011

ASP.NET 2.0 - Enter Key - Default Submit Button

A very simple and helpful tip from forum.asp.net
One of the most annoying things in developing web pages is handling the "Enter key" for form submission. Enter key has been the favorite way users like to submit forms. Though we provide Buttons to click on, the easiest and intuitive way is that, I can enter some text, make some changes and then hit "Enter" to accomplish my submission.





Friday, February 11, 2011

The Problem with Web Fonts

These day I'm stuck with the design for my current project due to lack of beautiful fonts for website. So I dug around and find this article on http://tympanus.net . This is not a new problem but sometimes we have to waste time in doing this. And then I find it very interesting to see my website with some amazing fonts by using @font-face with many font kits provided on Font Squirrel. That's it! No more words, check it out!
The problem with web fonts is that nobody wants to use the ‘safe’ fonts and you need as much live text on your site as possible. So what’s a designer to do? Fortunately or unfortunately there are plenty of options.
Unique fonts are awesome and up until a year or two ago the only way to accomplish unique typography was to embed them in images on your site. As semantic markup becomes moreimportant to browser compatibility and search engine rankings, live text is more and moreimportant also.
This means that we need to master the art of web fonts and how to get them to render correctly. There is no one real rock-solid sure fire way to present unique fonts yet, but there are a lot of methods you can use to accomplish unique active type. I have tried a few different methods, but my favorites are:

20+ High Quality Color Spectrum and Rainbow Wallpapers

You can’t imagine life without colors. Different colors give you different energy but when they come all together in form of spectrum or rainbow they give you freshness and happiness. So for your happiness and to give your desktop a full-of-life look, i have collected 20 high quality colorspectrum and rainbow wallpapers which you can download free by visiting the source site
Used Crayons by CeriseReve
Crayons Wallpapers