且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

“添加新项目" asp.net mvc下拉列表中的按钮

更新时间:2023-10-15 21:36:28

您应该处理下拉列表的事件.然后,调用对话框,用户可以在下拉菜单中输入一些值.您可以使用JQuery来实现以下目的:

You should handle the event of your dropdownlist.. Then, call the dialog where the user can input some value in your dropdown. You can achieve something like this by using JQuery:

$('#dropdownId').change(function (){
    var drpValue = $('#dropdownId').val();
    if(drpValue == "Add New Item"){
        //call method or show your dialog here;
    }
});

您仍然可以通过两种方法将其直接添加到下拉菜单中:

There are still two ways you can manage to add it directly to your dropdown:

  1. 回发
  2. 使用Ajax