问题
I have Ext.Net MVC form that post values to DirectAction. On server side, In DirectAction CoboBox selected value is always null.
public ActionResult Save()
{
var cmbSender = this.GetCmp<ComboBox>("cmbSender");
var senderID = cmbSender.SelectedItem.Value;
}
I have checked
Request["cmbSender"]
but it does not work
<form id="form12">
@(
X.TabPanel()
.Items(
X.FormPanel()
.Title("New Job")
.ID("pnlNewJob")
.Layout(LayoutType.Form)
.MarginSpec("5 5 5 5")
.Items(
X.Panel()
.Border(false)
.ColumnWidth(0.4)
.Layout(LayoutType.Form)
.Items(
Html.X().ComboBox()
.ID("cmbSender")
.DisplayField("Code")
.ValueField("ID")
.EmptyText("Code")
)
</form>
回答1:
You can use X.FormPanel()'s .Buttons() to post your form data. Add your ComboBox selected value Button's DirectEvent. An example :
.Buttons(
Html.X().Button()
.Text(AppTexts.Save)
.Icon(Icon.Accept)
.ID("SaveButton")
.DirectEvents(de =>
{
de.Click.Url = Url.Action("Save"); de.Click.ExtraParams.Add( new Parameter
{
Name = "cmbSelectedValue",
Value ="App.cmbSender.getValue()",
Mode = ParameterMode.Raw
}
);
})
)
来源:https://stackoverflow.com/questions/21043153/ext-net-accessing-combobox-value-at-server-directevent