如何使SingleChoiceAction_execute同步?

时间:2015-04-17 12:22:51

标签: c# download devexpress execute

我需要在singleChoiceAction_executed事件触发时下载文件。这是我的代码:

private void templatePickAction_Execute(object sender, SingleChoiceActionExecuteEventArgs e)
{
    Stream Stream = new MemoryStream();
    var item = View.ObjectSpace.GetObjects<xDicExcelTemplates>().Where(f => f.Name == templatePickAction.SelectedItem.Caption).FirstOrDefault();
    if (item != null)
        item.FileTemplate.SaveToStream(Stream);
        Stream.Position = 0;
        ResponseWriter.WriteFileToResponse(Stream, "1.xlsx");
}

但它在异步执行时不起作用。

如何让动作同步执行?

1 个答案:

答案 0 :(得分:0)

OMG。也许这对某人有帮助。好吧,在ProjectName.Module.Web(或只是ProjectName.Web)中,我需要打开Model - ActionDesign - Actions。然后我选择了我的动作并将IsPostBackRequired属性设置为True。这就是全部。

另外,要获取此属性的值

var choiceAction = (menuItem.ActionProcessor as MenuActionItemBase).Action as SingleChoiceAction;
bool usePostBack = (choiceAction as ActionBase).Model.GetValue<bool>("IsPostBackRequired");

这不是天才,但我很难找到