简体   繁体   English

下拉列表选择索引改变了剃刀

[英]dropdown list selected index changed razor

I am using razor view engine(cshtml) outside of mvc framework. 我在mvc框架之外使用razor视图引擎(cshtml)。 ie only view is converted to cshtml format. 即只有视图转换为cshtml格式。

I make all database calls using webmatrix and construct cshtml view. 我使用webmatrix进行所有数据库调用并构造cshtml视图。

Although, now i want to fire dropdown list selected change event which will set or fill contents of another dropdown list on the same page. 虽然,现在我想触发下拉列表选择的更改事件,它将在同一页面上设置或填充另一个下拉列表的内容。

Currently I use dropdown list using 目前我使用下拉列表

@HTML.DropdownList("ID",List)

on the selectedindex change of dropdown, i wish to check it's value and then decide on whether or not to populate second dropdown. 在选择索引更改下拉列表时,我希望检查它的值,然后决定是否填充第二个下拉列表。

How can I do it in this scenario? 在这种情况下我该怎么做? Remember, no mvc framework, hence no access to models or mvc specific methods. 请记住,没有mvc框架,因此无法访问模型或mvc特定方法。

when the dropdown list is rendered in the browser, it simply becomes a HTML tag and you can use vanilla javascript or frameworks like jQuery to check the item selected and load the next dropdown. 当下拉列表在浏览器中呈现时,它只是变成一个HTML标记,您可以使用vanilla javascript或jQuery之类的框架来检查所选项并加载下一个下拉列表。

Sample: 样品:

$( "#myselect option:selected" ).text();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM