Is there anyway to run an event after i selected a file in a Fileupload control, so i can set Label1.Text = FileUpload.FileName;
Or if any of you got another idea that would be awesome too(maybe some javascript)! :)
You can listen for the change event on the client side. Here's the syntax for IE but you can adapt it for the better browsers.
<asp:FileUpload ID="FileUpload1" runat="server" /> <span id="txt" />
<script>
var fu = document.getElementById('<% =FileUpload1.ClientID %>');
fu.attachEvent('onchange', function (e) {
document.getElementById('txt').innerHTML = e.srcElement.value;
});
</script>
I'm pretty sure good browsers will report only the filename, where IE with report the full path too (incorrectly).
addEventListener instead of attachEvent for browsers that require it? are you getting a proper reference to the element in browsers that don't support srcElement?