-1
我在ASP.NET MVC Core项目中有一个下拉列表。MVC Core:ViewComponent onload event equivalent
<div class="form-group">
<div class="col-md-10">
@Html.DropDownListFor(t => t.AnimalTypeID, Model.AnimalTypeList,
new { onchange = "performStuff();" })
</div>
</div>
的onchange
事件就像一个魅力,并隐藏某些含页字段(即,“皮毛颜色”或“喙类型”文本框),这取决于所述下拉选择。
我也想调用ViewComponent加载/准备的相同功能。有没有办法做到这一点?
I.e.我基本上希望能有这个相同的,如果这可能是可能的,请吗?
@Html.DropDownListFor(t => t.AnimalTypeID, Model.AnimalTypeList,
new { onload="alertFunction();" ,onchange = "performStuff();" })
<script type="text/javascript">
function alertFunction()
{
alert('hello world!');
}
</script>
你可以在你的解决方案中使用jQuery吗? – Ignas
当然,这是我可以感谢的选择。 – BunnyMcButchFluffykinsMarauder
在答案中增加了更多细节。 – Ignas