I'm trying to style an ASP.NET FileUpload control by hiding it and putting in my own controls. I'm doing this with jQuery:
$(function () {
$('input[type=file]').each(function () {
var fileUpload = $(this);
var textBox = $('<input type="text">');
textBox
.css('width', fileUpload.width() - 85)
.css('margin-right', 5)
.prop('disabled', fileUpload.prop('disabled'));
var button = $('<input type="button" value="Browse...">')
.prop('disabled', fileUpload.prop('disabled'));
fileUpload.change(function () {
textBox.val(fileUpload.val());
});
button.click(function () {
fileUpload.click();
});
fileUpload.after(button).after(textBox);
fileUpload.hide();
});
});
This basically works great, except that I need to click my submit button twice in IE (10). I can't reproduce this in jsFiddle, but I did make a stripped down ASP.NET project where it happens.
In Firefox, I don't have this problem. Anyone know where I can start to look?