Here is the code for to show the selected file name to lable control when file selected by using Fileupload upload control in asp.net
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(function () {
$('#FileUpload1').change(function () {
var path = $(this).val();
if (path != '' && path != null) {
var q = path.substring(path.lastIndexOf('\\') + 1);
$('#Label1').html(q);
}
})
})
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUpload1" runat="server" /><asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(function () {
$('#FileUpload1').change(function () {
var path = $(this).val();
if (path != '' && path != null) {
var q = path.substring(path.lastIndexOf('\\') + 1);
$('#Label1').html(q);
}
})
})
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUpload1" runat="server" /><asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
Comments
Post a Comment