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)! :)
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 use javascript ontextchanged
event, it will trigger your javascript function where you can get and assign text value
I don't have .net environment right now , but something like work..
<asp:fileupload runat="Server" id="fup" ontextchanged="javascript:assigntext()" />
javascript funtion
function assigntext()
{
document.getelementbyid('labelid').value = document.getelementbyid('fup').value;
}
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).