c# - MVC 无法将 lambda 表达式转换为类型,因为它不是委托(delegate)

标签 c# asp.net-mvc asp.net-mvc-4 devexpress

我想知道我是否可以这样做,或者有其他方法可以做到吗? 我构建它没有问题,但是当我运行它时它说:

CS1660: Cannot convert lambda expression to type 'DevExpress.Web.Mvc.RoundPanelSettings' because it is not a delegate type

代码:

@Html.DevExpress().RoundPanel(RPsettings =>
{
    RPsettings.Name = "rpnlNewUpdateConfigs";
    RPsettings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
    RPsettings.ShowHeader = false;
    RPsettings.SetContent(() =>
        {
            Html.DevExpress().CallbackPanel(CBsettings =>
            {
                CBsettings.Name = "cbpnlNewUpdateConfigs";
                CBsettings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                CBsettings.CallbackRouteValues = new { Controller = "Storage", Action = "Storage" };
                CBsettings.SetContent(() =>
                    {
                        @<table>
                            <tr>
                                <td>
                                    <table>
                                        <tr>
                                            <td>&nbsp;
                                            </td>
                                            <td>Type:
                                            </td>
                                            <td>
                                                @Html.DevExpress().ComboBox(cboxsettings =>
                                                {
                                                    cboxsettings.Name = "cbType";
                                                    cboxsettings.Width = 180;
                                                    cboxsettings.SelectedIndex = -1;
                                                    cboxsettings.Properties.ValueType = typeof(string);
                                                    cboxsettings.Properties.Items.Add("Path");
                                                }).GetHtml();
                                            </td>
                                            <td>&nbsp;
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>;
                        Html.DevExpress().Label(L1settings =>
                        {
                            L1settings.Name = "ErrorLabel1";
                            L1settings.Text = "Label1";
                        }).Render();
                        Html.DevExpress().Label(L2settings =>
                        {
                            L2settings.Name = "ErrorLabel2";
                            L2settings.Text = "Label2";
                        }).Render();
                    });
            }).GetHtml();
        });
}).GetHtml()

有什么猜测吗?

最佳答案

发现发生了什么。 以这种方式在 SetContent() 中不允许使用 asp.net 标记。 正确的做法是:

CBsettings.SetContent(() => {
    ViewContext.Writer.Write("<h1>Hello World</h1>");

    ...

});

很遗憾智能感知没有给出错误的线索。

关于c# - MVC 无法将 lambda 表达式转换为类型,因为它不是委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16941178/

相关文章:

c# - Foreach 更改未保留在 Linq 项目集合中

c# - 为特定请求禁用 ASP.NET session 刷新

c# - ASP.NET MVC : seperatation of concern for normal/admin user

asp.net - 如果 WebAPI 根据客户端凭据进行身份验证,则获取用户信息

asp.net - 使用 RouteMagic MVC 保留查询字符串参数

asp.net-mvc - 如何获取用户重定向到MVC4中当前操作的操作名称

c# - 在浏览器中打开word文档

c# - #if (DEBUG) 在定制的基类库中不起作用

c# - 特定行的 LinqToExcel GetColumnNames

angularjs - 我可以在 angularjs 模块配置方法中访问 MVC web.config 值吗?