[英]events in asp.net mvc application
controller 控制者
IEnumerable<SelectListItem> process =
from proc in
XDocument.Load("Processes.xml").Descendants("Process")
select new SelectListItem
{
Text = (string)proc.Element("ConfigFile")
};
ViewBag.process = process;
view 视图
<p>@Html.DropDownList("process")</p>
I want to handle an event on item selected in the dropdown list I Googled a bit and people say there is no regular event handler like normal ASP or WinForm application 我想处理下拉列表中所选项目的事件,我用Google搜索了一下,人们说没有常规的事件处理程序,例如普通的ASP或WinForm应用程序
I'm not familiar with javascript and jquery but i could understand a code 我对javascript和jquery不熟悉,但是我可以理解代码
You could put this DropDown inside a form and use javascript to subscribe to its onchange
event and manually submit this form: 您可以将此DropDown放入表单中,并使用javascript订阅其
onchange
事件并手动提交此表单:
@using (Html.BeginForm("SomeAction", "SomeController"))
{
@Html.DropDownList("process", Model.Items, new { onchange = "this.form.submit();" })
}
this will POST the selected value to the SomeAction where you could retrieve it: 这会将选择的值发布到SomeAction中,您可以在其中检索它:
[HttpPost]
public ActionResult SomeAction(string process)
{
// the process argument will contain the selected value from the dropdown
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.