May 07, 2012, 4:07 PM
[CLOSED] [RAZOR] How to access ext.net controls from controller method
Hi
I'm trying to access and manipluate a control defined in a .cshtml file (below) from the controller class implementing the ButtonClick event in the controller file.
I've tried X.GetCtl which doesnt work. Is this a way of getting a reference to the controls defined on a .cshtml page from its associated controlller?
View Code:
I'm trying to access and manipluate a control defined in a .cshtml file (below) from the controller class implementing the ButtonClick event in the controller file.
I've tried X.GetCtl which doesnt work. Is this a way of getting a reference to the controls defined on a .cshtml page from its associated controlller?
View Code:
Html.X().FormPanel()
.ID("Form")
.Title("Form")
.ButtonAlign(Alignment.Right)
.Layout("hbox")
.Items(items =>
{
items.Add(Html.X().DateField()
.ID("DateField")
.Width(120)
.DirectEvents(directEvents =>
{
directEvents.Select.Url = "/Common/DateField";
directEvents.Select.ExtraParams.Add(new Parameter()
{
Name = "Date",
Value = "item.value",
Mode = ParameterMode.Raw
});
}));
...
items.Add(Html.X().Button()
.ID("Button")
.Text("Button")
.DirectEvents(directEvents =>
{
directEvents.Click.Url = "/Common/OnButtonDirectClick";
}));
Controller Code:
public ActionResult OnButtonDirectClick(Args args)
{
...
// Get reference to the control
var ctl = X.GetCtl("DateField");
return new AjaxResult(msg);
}
Last edited by Daniil; May 11, 2012 at 4:32 PM.
Reason: [CLOSED]