Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在DropDownList http helper ASP.NET MVC中添加javascript事件_C#_Asp.net_Asp.net Mvc_Razor - Fatal编程技术网

C# 在DropDownList http helper ASP.NET MVC中添加javascript事件

C# 在DropDownList http helper ASP.NET MVC中添加javascript事件,c#,asp.net,asp.net-mvc,razor,C#,Asp.net,Asp.net Mvc,Razor,我有以下代码: <div class="col-xs-6 col-sm-3"> @Html.DropDownList("cssFiles", (IEnumerable<SelectListItem>)ViewBag.cssFiles, "Crear Nuevo", new { @class = "form-control", @id = "selCssFile" }) <span> <input t

我有以下代码:

<div class="col-xs-6 col-sm-3">
        @Html.DropDownList("cssFiles", (IEnumerable<SelectListItem>)ViewBag.cssFiles, "Crear Nuevo", new { @class = "form-control", @id = "selCssFile" })
        <span>
            <input type="text" class="form-control" id="txtFileName" style="display:none;" placeholder="Nombre del archivo">
        </span>
</div>

@Html.DropDownList(“cssFiles”,(IEnumerable)ViewBag.cssFiles,“Crear Nuevo”,new{@class=“form control”,@id=“selcsfile”})

我想添加一个Javascript事件,用于在选择“Crear Nuevo”时显示“txtFileName”,并在下拉列表更改时隐藏它。基本上,您需要在下拉列表元素上附加click事件

代码

$('#selCssFile').on('change',function(){
   //implement code after selected the option
});

您可以使用jQuery实现这一点。