Asp.net mvc 设置值的Html.textbox

Asp.net mvc 设置值的Html.textbox,asp.net-mvc,Asp.net Mvc,我使用和 x.FileName,在我的mvc项目中新建{@class=“className”,maxlength=255,id=“FileName”})%>。我想将在输入元素中选择的文件名保存在文本框中。我如何才能做到这一点?您需要使用javascript来实现这一点。以下是jquery的一个示例: $(function() { $('#fileId').change(function() { // When the user selects a file, read t

我使用

x.FileName,在我的mvc项目中新建{@class=“className”,maxlength=255,id=“FileName”})%>
。我想将在输入元素中选择的文件名保存在文本框中。我如何才能做到这一点?

您需要使用javascript来实现这一点。以下是jquery的一个示例:

$(function() {
    $('#fileId').change(function() {
        // When the user selects a file, read the selected filename
        // and set it to the textbox
        var filename = $(this).val();
        $('#fileName').val(filename);
    });
});